Tonight, I played with git hooks. Because I wanted to be able to regenerate the website remotely just by doing a push to a specific branch of the website repo.
By adding on the remote side in the bare git repo in hooks/post-receive (that you have to make executable):
#!/bin/sh read oldrev newrev refname BRANCH="production" if [ $refname = "refs/heads/$BRANCH" ]; then SOURCE_FOLDER=/src DEST_FOLDER=/www echo "Copying the git" GIT_WORK_TREE=$SOURCE_FOLDER git checkout -f $BRANCH echo "Generating the website" hugo -s $SOURCE_FOLDER -d $DEST_FOLDER --cacheDir $SOURCE_FOLDER/.cache fi
Just replace /src with a folder your git user has access to, replace /www by the place your web server will look and production by the branch that contains the production version.
I added the cacheDir option, because I don't want executable stuff in /tmp so pygments was complaining that it was enforced (complaining with a void error message, I had to strace it).