Migrated to Hugo

I really haven’t paid much attention to my blog in a few years. Part of that was probably due to the fact it was running on ColdFusion (Railo 3.3 really) using Mango Blog. Both are extremely out of date and started looking for an alternative. First thought was to convert to WordPress, but given the hassles to set it up and run it securely with seemingly constant vulnerabilties reported pretty much ruled it out.

I wanted to simplify the stack and reduce attack surface, so static generators seemed like a good place to start. I looked at Jekyll first and then several others but ultimately decided on Hugo.

The main reason I chose Hugo was that its quick start was straight forward and really do like the simplicity of install on macOS

brew install hugo

Migration

So like all things, migration is really the biggest hurdle. It was a multi-step process to get the data out of Mango and in to Hugo, using WordPress as an intermediate step since just about everything can convert to/from it. All the work to convert was done in an Ubuntu VM that had both ColdFusion and WordPress installed with a MySQL database dump of the existing Mango Blog database.

Marcos Placona wrote a script to migrate from Mango to WordPress. I had to do some modifications to the code since there was a variable scoping issue and it did not retain full date time stamps for posts and comments. With those were dealt with, it worked great and got the data into a shell WordPress site.

Once in WordPress, I tried using WordPress to Hugo Exporter but could not get it to work. I was able to use Jekyll Exporter instead since all I really wanted was the post content exported to Markdown files. Hugo has several options to convert Jekyll to Hugo but I did not use them and manually modified the exported Markdown into Hugo. Some of the posts had a lot of extraneous HTML markup that I wanted removed.

For comments, I needed to export a WordPress WXR file so I could import it to Disqus. I did need to modify the URLs for the posts in the WXR file to match what the new ones would be before importing.

Setup

With Hugo’s excellent documentation it wasn’t hard to setup. Biggest thing for me was to get a theme in place that had the features I wanted, mostly that it was based on Bootstrap 3. There are plenty of themes to choose from. Hugo Phlat Theme met my needs once I did a few tweaks to it.

The other change was using nginx instead of Apache httpd. Used Mozilla SSL Configuration Generator to generate nginx configuration to work with.

The other item needed were URL re-writes since the URLs no longer contained .cfm. Several posts of mine that are linked to various Stack Overflow answers, without the URL re-writes the links would fail.

# rewrites to map specific .cfm to new pages
rewrite    ^/feeds/rss.cfm$                              /index.xml permanent;
rewrite    ^/post.cfm/(.*)$                              /post/$1/ permanent;
rewrite    ^/archives.cfm/category/(.*)$                 /categories/$1/ permanent;
rewrite    ^/archives.cfm/page/(\d)$                     /page/$1/ permanent;
rewrite    ^/page.cfm/(about-me|projects|presentations)$ /$1/ permanent;
rewrite    ^/assets/content/presentations/(.*)$          /presentations/$1 permanent;

I’m sure there are going to be a few more things done to nginx configuration once I dig into it a bit more.

There are a few different ways to host and deploy content with Hugo. For now going with rsync until need a different flow.

Overall, I am quite happy with the change to Hugo and hopefully it will lead to me writing more frequent posts.