Hugo Makefile, up and running again!
Up and running, again!
This article is and update for the Up And Running, From Draft to Publishing in Octopress and Working Session With Octopress and Jekyll article managed using the same Makefile technique described in the Using Makefiles With Docker article.
The research
I simply followed the homebrew quick install process to get the utility installed.
Makefile
I created the following Makefile to drive the blog:
makefile_dir := $(abspath $(shell pwd))
publish_dir := $(makefile_dir)/../boundedinfinity.github.io
list:
@grep '^[^#[:space:]].*:' Makefile | grep -v ':=' | grep -v '^\.' | sed 's/:.*//g' | sed 's/://g' | sort
bootstrap:
brew tap Homebrew/bundle
brew bundle
bower install
edit:
hugo server --buildDrafts --watch
view:
hugo server --watch
purge:
rm -rf public/
publish:
@make purge
hugo --quiet
rsync -a --delete --exclude-from .rsyncignore public/ $(publish_dir)/
cd $(publish_dir) && git add . && git commit -m "update" && git push origin master
git add . && git commit -m "update" && git push origin master
edit
Runs the server
command with --buildDrafts
flag enabled
view
Runs the server
command without --buildDrafts
flag enabled
publish
The publish command turned out to be more difficult than I would have guessed.
After reading through articles and issue (like Clean output directory before generation) it seems like hugo doesn’t clean up the output directory during site generation.
I decided to do something simple. First I’ve added the default output
directory, public/
, to the .gitignore file.
I then just delete the public/
directory before the site generation.
purge:
rm -rf public/
publish:
@make purge
hugo --quiet
I then used articles like
How do I make rsync delete files that have been deleted from the source folder? and
6 rsync Examples to Exclude Multiple Files and Directories using exclude-from
to rsync the local generated directory the the $(publish_dir)
directory
which is the directory that gets pushed to the
Github Page.
The last thing the target does is to push the source into my private blog branch.
Other things
Before I got to this point I had to figure out how to do a number of things in Hugo that wasn’t as batteries included as I would have liked. These are listed here: