03 Aug 2015, 11:47

Going static


Moving from Wordpress to Hugo

This blog started as a place to collect and share technical tips and tricks about 10 years ago.

All that time it was powered by WordPress. But since this was constantly giving me headaches about the security issues and because I was using virtually no features of WordPress I dedided to put an end to that.

What I really wanted was a way to easily write and edit small pices of text, preferably no HTML, and a way to publish that to the web.

Static site generators (like Jekyll or Hugo) give me everything I need for that. By keeping the source files in Git I can easily edit the content anywhere I have a clone of the repo.

A simple post-commit hook will trigger a rebuild of the site. So publishing is as easy as pushing to Git.

The post-commit hook is produced below. Put it in the REPO_PATH/hooks (or custom_hooks for GitLab) and make it executeable to enable it. For debugging set the QUIET flag to an empty string.


while read oldrev newrev refname
        branch=$(git rev-parse --symbolic --abbrev-ref $refname)
        unset GIT_DIR
        if [ "x$branch" != "xmaster" ]; then
                echo "Ignoring push to non-master branches"
                exit 0
        satdir="/tmp/REPO-NAME-TEMP"  # TODO change me
        if [ -d "$satdir/.git" ]; then
                echo "Updating existing satellite"
                cd $satdir
                git pull $QUIET
                git checkout $QUIET master
                git submodule init $QUIET
                git submodule update $QUIET
                echo "Cloning new satellite"
                mkdir -p $satdir
                git clone $QUIET $REPO_PATH $satdir
                cd $satdir
                git checkout $QUIET master
                git submodule init $QUIET
                git submodule update $QUIET
        cd $satdir
        rsync $QUIET -Haxe ssh $satdir/public/ SERVER:/path/to/docroot/ # TODO change me

This setup is performant, flexible and also allows for easy collaboration. Collborators can send in their articles as text (Markdown) or given access to the git repository. Since I am using GitLab for repository access management this is very easy as well as editing articles using the GitLab webinterface.