Static blog with Hugo

Recently I have been looking for a simple blogging platform to write about some things I have learned. I don’t expect much traffic, and I don’t need any advanced features.

Here are my requirements:

  1. No monthly fees (I don’t blog enough for it to be worth it)
  2. Easy integration with my existing server setup ($10/month linux box on digital ocean)
  3. Comments
  4. Minimal responsive design

My solution

I decided on Hugo. Hugo is a blogging platform with 0 runtime dependencies. This means that after you build your blog, all you need is a web server (nginx/apache) and a server.

The lack of a runtime means that you could even host your entire blog on a CDN!

Theme/Design

Hugo ships with a few themes. Not all seem to work correctly. I also didn’t see any themes that supported pagination (Added in version 0.13). Luckily Hugo has very nice template syntax and adding your own themes is very easy.

I bought a $14 HTML theme from ThemeForest.net and converted it to a Hugo theme. Luckily Hugo has a very easy template syntax. An example of loading all posts from a certain page would be:

{{ range .Paginator.Pages }}
  <h4 class="post_title"><a href="{{ .Permalink }}">{{ .Title }}</a></h4>
  <p>{{ .Summary }}</p>
{{end}}
Writing a Post

Blog posts are written in a Github style markup. You can use any markup editor to write the posts. Mou or the Atom editor work well, and have a preview mode.

Adding Comments to your Blog

Because Hugo does not have a runtime, it doesn’t ship with any sort of comment functionality. I decided to use Disqus and was able to add it in a few lines of HTML and Javascript.

Another option here would be to use Facebook comments if you prefer.

Publishing your blog

The final piece of the puzzle is to publish your blog. The process of generating the HTML is actually pretty simple. From your blogs content root, run the following command:

/path/to/hugo --config=/path/to/config.toml

Next, just make sure that your nginx or apache server is pointed at the /path/to/hugo/public folder and you can start serving up content!

My Experience so far

Overall, using Hugo has been a very nice experience. I really like not having to install PHP or Node.js on my server (along with the dependenceis) that so many blogging platforms require.

The markup language can definitely get to be annoying and may require modifying some CSS to get things looking just right, but the pros outweigh the cons in my opinon.