This site is created with Hugo, a static website generator written in Go. As a learning exercise, I'm writing the necessary HTML templates by hand as I go along, which probably explains some of the weirdness.

Push to deploy

This website is deployed from a git repository. When I push new commits, the repository on the server runs a post-receive hook that checks out the contents and executes hugo on it:

export GIT_DIR=~/hugo/.git
export GIT_WORK_TREE=~/hugo 
git checkout -f 
${HOME}/bin/hugo -s ~/hugo -d ~/Public

Note that ~/hugo/.git was first created as a bare git repository (via git init --bare) on the server and added as a remote to my local git repo where all the editing of these pages happens. The forced git checkout to ~/hugo (via the GIT_WORK_TREE environment variable) makes it look like a regular repo. The work tree is however unregistered:

localhost:~/hugo$ git status
fatal: this operation must be run in a work tree

If enableGitInfo is set to true in config.toml, hugo will try to get page timestamps from git. If the GIT_DIR environment variable wouldn't be set to ~/hugo/.git, building the site would fail:

ERROR 2022/08/17 19:34:36 Failed to read Git log: fatal: not a git repository: '.'

Together with enableGitInfo = true in config.toml, I also get page modification timestamps for free.

To sum up, any local changes that I commit to my local repo will automagically be published once I push to the server remote.

Pages linking here