Tuesday 6 January 2015

On Creating Static WebSites with docpad and hugo

One thing I've grown to distrust is Wordpress security.

This is less of an issue now that wordpress makes upgrading to new versions easier, and partly auto updates.

But I've been investigating static website generation to try and avoid this issue. After all, who really wants the hassle of updating wordpress, when you need to focus on consultancy and product development.

I could simply host on wordpress and have them update the security etc. Or move everything over to blogger, (but I'm really only doing that as a temporary measure). And I don't use that for my main sites.

And I like the flexibility that having control over the web server gives me:

  • creating custom client areas
  • adding extra software etc.
As a result I investigate docpad, and it was pretty simple. It has a lot of flexibility because of node.js but there were still things I couldn't do very well that I wanted to and the rss generation broke recently (and that is an essential feature for me).

So I migrated over to Hugo yesterday.

It took a few hours to migrate (about 4), so nothing too bad.

It has some 'bugs' i.e. the docs suggest that the rss feed should generate as rss.xml but it comes out as index.xml

It has some missing 'features' i.e. the 'where' clause handling on the 'range' selection doesn't handle custom Params yet.

But, I was able to work around all of that.


Benefits over docpad for me:
  • slightly simpler to use
  • more active development
  • no plugins required for rss generation or template handling
  • easier to test because in server mode the permalinks are (localhost) I can actually test it locally without links being external (I use xenu to check)
  • much much faster than docpad
Drawbacks:
  • less powerful longer term
  • harder to generate .php files etc. (so I'll need to create some sort of post processing step for some of my sites)
But the rss works, the sitemap is generated automatically. Helper pages e.g. indexes are generated automatically. There is a lot of flexibility to explore.

I'll see how I get on with it over time, but for the moment.
  • cd <sitedirectory>
  • use "hugo server -v --buildDrafts --watch" for development
  • use "hugo" to build for production release and copy the contents of 'public' to the website
I found a set of useful tutorials over at http://npf.io/