I want to build my site on commit, here’s what I tried first:

set -eux

rm -rf public
git add public
echo "updated build directory"

This worked! But it took some fiddling because I mistakenly set the date of this post in the future. Apparently you can do that and Hugo won’t add the pages for it, so it was running the build command but not actually updating anything.

I started out googling around for a specific Hugo one, and ended up in a rabbit hole of people setting up servers for ‘post-receive’ hooks and an NPM package for linting called Husky, and a python package for pre-commit modules. What I wanted was much simpler, so it was easier to start from the git docs and mess with the pre-commit.sample and rename to remove .sample.