2019/07/20 Switching my bloging engine

For quite some time, ther were no new posts in this blog and the reasin was not, that there was nothing to tell. The reason was that the system I was using up to now to write by blog posts was annoying. It took some time, but now the new system is good enough to be used, while it is still in Beta. The most important criterion for a new system was, that is should still generate static sites, because my blog does not need any dynamic pages. Furtunately lately static site generation became popular again, so that there are some for that purpose available agin. I’have choosen one of the more popular ones, Hugo, because it has all features I need and because of an additional tool for it. I do many things in Emacs, so ox-hugo was the thing driving me towards hugo. Ox-hugo is an Org exporter backend, that exports Org to Hugo-compatible Markdown, generates the front-matter nedded and allows to have multiple pages (to be precise, in my case the complete page) in one org file. It also allows to export only blog-posts that are marked as finished and thus allow me to commit not finished blog posts, while still using CVS and auto deploy on each commit.

So how is the setup: I have a CVS repository where my complete site resides. This is a generally a normal hugo site, initially generated with hugo new site. The theme for my site is self-written, because I want one without all the fancy javascript, just simple HTML. My org-files for the site (currently it is only one, but more are generally possible) reside in the content-org subfolder. Normally generating the markdown files out of it would include opening the file in emacs and pressing some keys, but due to the bach mode of emacs, this can easily be automated. After generating the Markdown files, just hugo must be run and the files need to be copied to a folder where the webserver picks them up. Note, too old versions of Hugo have problems with directories, where a CVS directory is in.

Here is the Makefile for it:

all: blog

blog:
	rm -rf content
	emacs --batch -l emacs-do-export.el content-org/posts.org -f org-hugo-export-all-wm-to-md --kill
	hugo
	rm -rf public/CVS

clean:
	rm -rf public content

.PHONY: all blog

And the emacs-do-export.el:

;; Use more memory
(setq gc-cons-threshold 50000000)


(require 'package)

(setq package-archives '(("org"   . "https://orgmode.org/elpa/")
			 ("gnu"   . "https://elpa.gnu.org/packages/")
			 ("melpa" . "https://melpa.org/packages/")))

(package-initialize)
(package-refresh-contents)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(require 'use-package)

(use-package ox-hugo
  :ensure t
  :after ox
)

(defun org-hugo-export-all-wm-to-md ()
  (org-hugo-export-wim-to-md :all-subtrees nil nil :noerror))

The batch file for emacs is set up an way, that allows to use it even from a completely fresh emacs install. It installs alle necessary packages itself.

Then there is a simple wrapper script handling the deployment and one line in the loginfo for that repo:

^blog (echo ""; date; echo %{sVv}; cat; (sleep 2; cd /home/christian/DEPLOY/blog; cvs -q update -d -P; ./deploy.sh;) &) >> /home/christian/CVS/Admin/CVSROOT/updatelog_blog 2>&1

That is the complete setup and it is very plesent to use.

A few more features I want to mentiion.

and many more.

I’m pretty satisfied with my new setup and the workflow it imposes and hope to put the system out of beta soon.