Switching to Hugo

in   , ,

After a few years of silence on the blog front, I tried to switch my website to use HTTPS everywhere. However, the existing Middleman based website had references to insecure HTTP resources, which caused a blanket switch to HTTPS to cause the site to fail to load correctly.

At the time I wanted to rebuild my templates to use HTTPS, but by then, Middleman had been upgraded from 3.x to 4.0, causing my work to crash and burn. I managed to somehow get a copy of 3.3.0 (I think), but it was running so slow on my Macbook, that I needed to find some other static site generator.

While Hugo was available at that time, I made the mistake of not trying to port it at the time. I instead fell back to Pelican , which ran fairly smoothly at the time. However, due to time constraints, I did not try to build my own templates, but used a generic Bootstrap 3 template that was freely available. I did make some modifications to support my Stardates tweak, but that was about the limit of my modifications.

Finally, I decided that it was time to kickstart blogging again, but Pelican was getting slow, and having to set up a virtualenv was not particularly appealing to my senses. Hugo appealed to me as a single binary that I could download and run, without any dependencies. Not to mention, it was extremely fast.

I also decided to switch to Bootstrap 4, which did require me to rewrite the template almost from scratch, but a thorough perusal of the Bootstrap documentation, Hugo discussion forums and Stack Overflow helps me get almost everything that I need.

While there is no support for plugins, the template system makes up for that in spades. You can perform limited arithmetic within the template itself, which lets me generate the Stardates for the post dates, as well as the weighted tag cloud in the sidebar. With a generous helping of the built-in server and template debugging functionality, it’s quite possible to build your own template in a matter of days.

Hugo already has a number of built-in templates and shortcodes which you can use in your content, one critical one being syntax highlighting. Hugo has a built-in syntax highlighter, similar to Pygments, and outputs similar markup. With just a single line in the site configuration, you can generate syntax highlighted code in a number of predefined styles.

With that being said, my template is not perfect - it still throws warnings for missing templates, but so far, I have not seen any issues caused by these warnings. I may eventually get around to fixing them, but for now, this is good enough.