Github Pages + Hugo = Love

September 13, 2015
Golang Hugo

I was aware of Jekyll and Github Pages long time ago, but I didn’t want to have Ruby environment to generate my blog, so I’ve ended up with Ghost blog on DigitalOcean.

Few months ago when I was on vacation I started to learn Golang:

And of course I found Hugo. But I was busy and had no time for my blog until now.

So, what’s Hugo? Per gohugo.io:

Hugo is a general-purpose website framework. Technically speaking, Hugo is a static site generator. This means that, unlike systems like WordPress, Ghost and Drupal, which run on your web server expensively building a page every time a visitor requests one, Hugo does the building when you create your content. Since websites are viewed far more often than they are edited, Hugo is optimized for website viewing while providing a great writing experience.

And since it’s static site you can host it on Github Pages (for free!). And the most important is that you don’t need to maintain server/web application yourself, any change to your blog is just a commit to repository using Git. But previously I had to update Ghost theme, Ghost version manually using FTP.

It took me one evening to migrate from Ghost to Hugo, the main problem for me was to choose theme or create my own :) Current theme I use called Cactus and it’s open source.

But now It’s a matter of a commit to change/add anything on the blog. I use this script to deploy my changes:

#!/bin/bash
cd vort3x-blog-hugo

# Build the project.
hugo

cd public

git add -A

# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

# Push source and build repos.
git push origin master

I want to thank Steve Francia (spf13), the creator of Hugo and all contributors on Github (208+ at the time of this writing)! Great job!

Feel free to ask me any questions in the comments below.

comments powered by Disqus