Moving to Hugo and Cloudflare Pages

tl;dr: I migrated my blog from Jekyll to Hugo. It seems more better. I did my best to fix everything, but you find something broken, do let me know.

Previously, I had set my blog up on Github Pages with Jekyll as the SSG. I found Jekyll increasingly difficult to work with since then, so decided it was time to modernize by switching to Hugo. The directory structure makes a lot more sense with Hugo, and builds are noticeably faster. Getting it set up on a new box is also way easier, since you don’t have to fight with all the Ruby dependency nonsense. It’s pretty much a self-contained package.

GitHub pages was also somewhat annoying to get set up, but at least once it was configured it was set-and-forget. However, I took this opportunity to migrate anyway. I had set up some other blogs on Cloudflare Pages and found it very easy to work with. Builds of my site are faster there than they were with GitHub, but that might just be because of Hugo anyway. Since I already manage my DNS with Cloudflare, it only took a few clicks to get set up with a custom domain and all.

I did have to make a few changes to content to get everything working nicely.

I moved all my posts from standalone markdown files to directories, so I could co-locate the related images with them. First, this meant I had to change all of the image references from absolute to relative URLs – that was simple enough.

Next, I had to do something to avoid breaking existing links to posts. With Jekyll, my filenames for posts would result in urls like /posts/slug, so I added the corresponding slug to the front matter of each post with this awful one-liner:

$ for f in ./*; do slug=$(echo $f | sed -re 's/^.\/[0-9-]+//'); sed -ire "/date: /e echo slug: $slug" $f/; done

The final major fix was to get all the inline math rendering nicely with KaTex. Previously, I used one macro for all math, and had it all rendering as inline. That macro now made it all render as block, so I had to configure a custom one for inline and update all the posts that needed to use it.

Of course, theme customization was also necessary, and is largely still in progress.