Hugo Site Deployment

When I started publishing the blog I was using the git subtree approach, as suggested in the hugo documentation. However, I tend to mess up my setup when I amend or rebase when working with the local site.
Since I like to keep things simple, I have switched to keeping the generated site in a separate git repo, which I deploy by manually pushing to github pages.
The benefit of this is that I get to review the changes manually before deploying to the live site.
Workflow
Here is the basic outline of my workflow.
- create and edit some content
- review changes by serving up the site locally
- make as many commits as desired in the site hugo sources
- build the site for deployment
- review changes to the deployment git repo. I deliberately want to keep this step manual, since I am using the latest sources for hugo, and sometimes bugs causes weird things to happen to the ouput.
- push deployment repo to github
Makefile
The workflow may seem a little complicated, so I am using a Makefile I have created to avoid having to remember all the commands to type (or mistype, and screw up my site).
DEPLOYMENT_REPO=stou.github.io
all: server
build: dist
help:
@echo "\033[0;4mAvailable targets:\033[0m"
@echo " server - serves up site locally (default target)"
@echo " build - build the content for deployment in ${DEPLOYMENT_REPO}"
view:
# open front page in browser
open http://localhost:1313
server: clean
# Server the site up locally
hugo server -w --buildDrafts=true
clean:
# clean out the local server build artifacts
-rm -r public/*
dist: dist-clean
# Build the project for publishing
hugo -s . -d ${DEPLOYMENT_REPO}
dist-clean:
# clean publishing output dir
# NB: Avoid removing the .git folder
-rm -r ${DEPLOYMENT_REPO}/*
This allows me to serve up the site locally simply by running make
.
To build the site for deployment I run make build
.
For the git operations, use whatever tool you are most familiar with. I personally like a combination of the command line and gitx, since I am using the Mac.