Hugo Migration

Migration of WetzDev to Hugo-built static site.

2016-12-20

Quick History

The initial version of my portfolio here on WetzDev was an Angular 1.x web application. It was read-only with JSON files on the server; it was simply a proof-of-concept. After a little while I added a server component in Nancy that worked with DocumentDB on Azure. I re-used some image management logic I created for WetzNet. As I was already re-using code, I simply made the admin screens in Nancy and kept Angular as a readonly front end.

Why Hugo?

In the past I’ve created custom static generators in Python and C#, but this time around I thought I’d try something new. As many others have noted, Hugo has the benefit of an xcopy installation and is incredibly fast. Just perusing the docs it was clear the templating system was pretty simple to use, and content supports github-flavored markdown so more or less all of my boxes were checked.

Migration

I wanted to create a new theme from scratch so that I’d get a good feel for the tool. I still referenced existing themes, as the documentation is decent but often pretty short on examples.

The theme files are html sprinkled with “{{ logic }}”. Similar to other systems (static or dynamic) you can setup a base template “baseof.html” that defines blocks for page templates to override as needed (e.g. Html title can default to the site name, while a specific page will probably want something else). Similarly, it uses the concept of partial templates to let you farm out logic (e.g. “footer.html” for copyright info). I initially didn’t know about the base template, so I had to rework some things to get it to work. And even then I had to work around an issue where pages defined in content aren’t using it for some reason (I’m guessing bug, but it could be “by design”).

Speaking of content, it’s nice and easy to add new items. Simply add a new markdown file in the correct folder, add some header info, and then just put in whatever content you like in markdown. Well, sort of; that sort of broke down for me because I often wanted to alter the layout, which required putting in html. Sometimes it didn’t mind mixing markdown with html, but other times the markdown would simply stop rendering correctly. As a result, all of my project pages are html with no markdown.

As for publishing content, I simply used S-FTP and uploaded the generated public folder. I don’t plan on making changes often, so I probably won’t automate it. However, it is worth mentioning that these days it is easy to do and many hosts will let you use git or SSH. Of course since it’s static, you can simply skip a web host entirely and go with a cloud service like S3!