Skip to content

Instantly share code, notes, and snippets.

@wlonkly
Created December 31, 2025 13:17
Show Gist options
  • Select an option

  • Save wlonkly/31b6ca979638f9dabcc64c44a86ff97c to your computer and use it in GitHub Desktop.

Select an option

Save wlonkly/31b6ca979638f9dabcc64c44a86ff97c to your computer and use it in GitHub Desktop.
rich's hugo publishing stuff
publish:
scripts/publish.sh
force-publish:
scripts/publish.sh -f
post title:
hugo new "posts/{{title}}/index.md"
code "content/posts/{{title}}/index.md"
server:
scripts/server.sh
#!/bin/bash -eo pipefail
RSYNC_CHECKSUM='--checksum'
IFS=' '
GIT_STATUS=`git status --porcelain`
if [[ $1 == '-f' ]]; then
# upload everything even if it matches
RSYNC_CHECKSUM=''
elif [[ $GIT_STATUS ]]; then
echo "Commit changes to git before publishing!"
echo "Uncommitted changes:"
echo $GIT_STATUS
exit 1
fi
hugo
rsync -av --delete --progress $RSYNC_CHECKSUM public/ minnow.mati.ca:sites/lafferty.ca/hugo/
#!/bin/bash
cleanup () {
rm -f /tmp/hugo.lock
}
exec 100> /tmp/hugo.lock || exit 1
if ! flock -n 100; then
HUGO_PID=$(pgrep -f hugo.*server)
echo "hugo is already running (pid ${HUGO_PID}), exiting"
exit 1
fi
trap cleanup EXIT
(sleep 1; open http://localhost:1313/archives) &
hugo server -D -p 1313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment