Hugo flow and deploy process

March 29, 2016

This one will be in english, french translation will come later

This log is supported by Hugo, a free and open-source static site generator similar to Jekyll. Hugo is pretty straightforward to use:

$ hugo
0 of 1 draft rendered
0 future content
2 pages created
1 paginator pages created
0 tags created
0 categories created
in 27 ms

…and well-documented.

Basically to publish things you need to edit the markdown files on the content folder on the server and run hugo to refresh the public folder served by nginx.

But writing things using ssh on a server is not really usable, so here’s another workflow:

  • do edition on your desktop
  • manage it with git
  • push changes to server
  • refresh hugo on server

All you have to do is setup a bare repository on the server to push into and a clone checked-out copy somewhere else on the system where your web server can watch it. Here is a hook to put in git-bare-repo.git/hooks/post-receive:

# Don't forget to chmod +x

unset GIT_DIR
cd /var/www/website-chekout-repo-dir
git pull

Example output when you push to the repo:

remote: From ../
remote:    a4ced08..dbad211  master     -> origin/master
remote: Updating a4ced08..dbad211
remote: Fast-forward
remote:  content/post/ | 8 ++++++++
remote:  1 file changed, 8 insertions(+)
remote: 0 of 1 draft rendered
remote: 0 future content
remote: 2 pages created
remote: 1 paginator pages created
remote: 0 tags created
remote: 0 categories created
remote: in 28 ms

As you can see the hook’s output is displayed, yay !