Switching to Hugo
I have switched from using Wordpress to using a tool called Hugo for editing and publishing the articles on the site. Wordpress is a fine tool for the most part. Hugo (and probably other static site generators) just fits my needs better. I don’t need or use any of the more dynamic features that Wordpress can provide. Static that is easily to publish is right for me.
The main thing I was not happy about with Wordpress was that all the editing was online, the editors were annoying for me to use, and having archival backups was not simple. There might be ways to make all these better, but they did not jump out at me even after kicking around the Wordpress bushes for a while.
With Hugo (and probably other static site generators), I can edit on my local machine using my preferred text editor. Since all of the documents are text files, with some not-overly-large images, I can use git
to manage the archival work. This how I do all my other work during the day, so it fits better with my style and patterns. The content processed by Hugo is all markdown files. I am very familiar with markdown and am happy to write using it. Hugo’s generator translates the markdown plus the theme templates into HTML for use on the web.
Since I do not need (or much want) comments on the blog, not having comments is not a problem for me. There do seem to be ways to connect Hugo to things like Discourse, but that’s also not something really useful for me. Same for forms and other dynamic context.
I moved to Hugo on a nudge that came from a mention of using Hugo by Clay Dowling. A day later, I installed Hugo and read some of its docs. It looked pretty good and had good support around, so I took the next step. That was to find a way to export my current content from Wordpress.
I used the exporter plugin from Cyrill Schumacher to get something out in some Hugo-friendly format. It did that reasonably well. I put the useful bits into the right folders (wp_contents
into the static folder, everything else under content
). And there, I have all the content. It was not nicely formatted, but it was there.
That meant learning about themes. After some reading and trying a couple of published themes, I took the Hyde theme and reused much of it to make a theme of my own. I did this instead of just using Hyde, because it was clear that I wanted something a bit different and would have to modify the theme anyway. It was just easier and cleaner (to me) to reuse the source (MIT License) than to use git submodules or golang modules to use the theme.
With it looking pretty good on the local server (another benefit of Hugo), I replaced the Wordpress version with the static version. This was also pretty easy. I exported my Wordpress data as a backup (regular export, not the Hugo export). I uninstalled Wordpress from my Dreamhost-hosted website. I built the new version of the site with Hugo to prepare it for uploading. The zipped results from the build where uploaded to the website folder where it unzipped itself (a feature of that file manager). That was all it took to make the new static content be available to the world.
I spent some time creating a script to automate the deployment. The two hardest parts of this were related to the uploading. On the Dreamhost side I needed to do enough poking and learning to figure out that sftp
was not really an option even though that is what Dreamhost pushes you toward. For some reason it can be used though a client (I used Filezilla), but would not work from a command line. That’s OK, because I am comfortable with ssh
and scp
and that works after making the right settings on the site manager. The second hard part here was doing enough learning to figure out how to make those work from the CI build (Github workflow). The magic here seems to be using the flags that automatically accept the new server (-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
). I can probably change that to using an ssh key from the CI machine, but that’s more tricks to learn. With that automation in place and a workflow defined on the Github repository, I have an way to publish new content with a push from my local git repository.
All in all, I spent a few hours spead over a couple of days filling in time while taking care of Mary and her shoulder (rotator cuff repair surgery three days ago). It was a good way to have something to do that could be easily interrupted. Now I will review this article on the local Hugo server (very nice to be able to preview locally), commit it, and push it so that you can read it from wherever you are.