Hugo & git submodules
Themes as submodules
This is well documented elsewhere, but that doesn’t mean I can remember it, or where to find it. The theme for this site is added as a git submodule. That means that when you checkout the repository and run hugo you’ll end up with a blank white page because the theme directory is empty. The submodule(s) must be initialized and updated before they will be found, e.g.
$ git clone https://gitlab.hippo-toes.com/iana/hippo-toes.git
$ cd hippo-toes
$ git submodule init
$ git submodule update
After those steps it should be possible to build the site HTML.
Publishing the site
On other repositories the site is usually published by pushing to a gh-pages branch (github.com). I generally do this with git worktrees, and a publish.sh script. I decided to do the same thing with this site, but since things can be manually propagated to the webserver the publish.sh script becomes even simpler
#!/bin/bash
DIR=$(dirname "$0")
cd $DIR
if [[ $(git status -s) ]]
then
echo "The working directory is dirty. Please commit any pending changes."
exit 1;
fi
echo "Deleting old publication"
rm -rf public
mkdir public
git worktree prune
rm -rf .git/worktrees/public
echo "Checking out gh-pages branch into public"
git worktree add -B gh-pages public origin/gh-pages
echo "Removing existing files"
rm -rf public/*
echo "Generating site"
HUGO_ENV="production" hugo
echo "Updating gh-pages branch"
cd public && git add --all && git commit -m "Publishing public to gh-pages" && git push
As a final step, you might need to restart the nginx-fyodor container because I set it up badly :-).