Oh jeez, your site is so fast now. Also it’s changed in design a little. What’s up with that? Asked nobody. Here’s the answer though: I moved from WordPress to the static site generator Hugo

That sounds super hipster

It probably is, I had a bit of a beard going on when I made the decision to move over. I’m also hosting it using Netlify so that’s pretty hipster too.

Have a click around though, look how fast everything is! Static HTML, the likes of which we’ve not seen since the early 2000s!

Why tho

As with all things the reason I did it was money and an absolute “Oh man I gotta try that” nerd instinct. I had initially set up my WordPress server a bit too beefy for what it needs, it was (and at the time of writing is, still got one more blog to convert!) something like $15-20 a month for three blogs that nobody really visits. That’s not ideal, that’s not optimized!

While I was procrastinating Yet Another Server Move™ I somehow stumbled across Hugo. Now I’ve never really been into the idea of static site generators because they’re always written in Ruby and I don’t like Ruby (One pain in the butt install that didn’t work and I dropped it into the pile along with Java and Windows web servers. I know, I should really give it a proper go one day)

Hugo though is written in Go which is the special new thing the internet is all over and more importantly I’ve never had any problem making things written in Go work. Nice!

I set up a quick site to give it a test and see how it all worked and man, I tell you what. I fell in love with the idea of storing everything in git and auto deploying and writing in markdown. All of the yes! Mainly the git part though to be honest. Blogs are just text, text goes in git. Nuff said.

Oh right. How’d the move go then?

Reeeasonably well. I used SchumacherFM/wordpress-to-hugo-exporter to convert the posts from WordPress into a more Hugo-friendly format. Needless to say it did not work first time, the plugin had some weird issue where it had functions defined twice in multiple places and everything just started falling apart. Honestly I’d have given up here and rage-deleted the plugin and not converted but I happened to have the error log open and saw the problem. Fixed up the plugin and tried again, it chucked me a nice zip file with all of my content..

Almost all of it. In WordPress I used a custom post type (or was it Jetpack? I don’t know) of ‘portfolio’ which is the projects on the sidebar there. The plugin does not export custom post types. Alright so we go in and edit the thing that does post type and include our portfolio posts and run again. Eyy that one worked better. Oh wait no it didn’t. Jump back in to the plugin and add a bit of code that allows us to also export the portfolio type as well as select it from the DB. Boooriiing.

But that time it worked, so I moved on. Next up I had a look at the Hugo themes directory and found the theme Hyde and essentially it looked exactly like my existing theme in WordPress. Now we’re getting somewhere!

Netlify is a thing

I figured as with all hipster products that Netlify would be something like 300 quid a month or something and barely do what I can do with a $5/mo DigitalOcean box. Nope, it’s free. It’s also pretty f’in great at what it does too. Free does usually mean that things are going to go out of business one day but in this specific case it doesn’t matter because everything’s in git, we just deploy someplace else if everything goes offline. Those folks over at Netlify seem to know what they’re doing too and they do have paid plans for larger sites. They’ll be fine.

I tried out Netlify because they’re doing in one what I was planning on doing with a combination of DigitalOcean box, Laravel Forge and Cloudflare. Optimization, baby!

Building a static site every time I mess up

The only problem I’ve had so far is my tendancy to edit things I write like 800 times before I’m happy with it. As an example of this if you look at my Reddit comments it’s rare you’ll find one that doesn’t have the edited asterisk on it. I’m actually writing this post right now so I stop editing and deploying the DigitalOcean Firewall post I just published over and over. It’s done, me, leave it.

In WordPress it’s a quick “Edit post” and save, nobody’s any the wiser that anything ever changed. Learning Hugo has meant that firstly I put the post in the wrong place in the site (its original URL was something like /post/digital-ocean-whatever) but I like to have posts to this site on the base domain. Fixed that. Pushed changes. Got it wrong, now it’s under /posts/! Damn! Fixed that, pushed change. Actually fixed - but oh no, now there’s no redirects and all my IFTTT applets have already fired and published the post everywhere

Add in aliases. Also add in a redirect rule for Netlify specifically. Push again.

Oh the wording of that post is just.. awful. So many short sentences I started reading it like that Stevie guy from Malcolm in the Middle. Edit, build, deploy.

At this point I shortened my workflow by creating an alias that runs hugo, adds to git with a horrible message “updated blog”, does a git push. Now of course I’m making tiny edits and pushing new versions of the site so frequently that the previous edit hasn’t even gone through the deploy process yet. At some point someone at Netlify’s going to call me and tell me to knock it off.

My workflow’s going to have to change without having a preview button. I’ll have to remember to run the local server in draft mode and read the posts before publishing them (side note during edit 327 of this post, I’m doing that with this one and it works perf. mate).

Honestly though, no big deal for the end results. Have you seen how fast the site is right now??

Comments tho, how do I call you a nerd right to your face now?

This was the more nerd-tickling problem. I somehow need to embed discussions in a static site. No big deal right? Just use the inbuilt Disqus thing. Nahhh, boring. Also GDPR and Disqus maybe maybe-not adding ads and all that. Not my style.

So I searched to see what others were doing. I’d remembered the Monzo blog did the sort of thing I was after. A self-hosted community that auto-posts a new topic whenever there’s a new blog post. That’s the ticket right there. I installed Discourse three times (Tried docker, tried to bodge it baremetal, went back to docker) and dug into the embed options and set all that up, as ye do.

So now under each of these posts there’s an embed fired off using javascript that pulls in the relevant thread (or creates a thread then does it if none already exist) and chucks the comments below the post. Boss life.

… I also then added the embed to basically every site I run and so now the forum I set up (talk.icnerd.com) is just chocka full of posts where each post is visited for the first time and a new thread is created. Honestly I sort of love it, even if there’s no community. Got damn I do love it when moving parts just work.

Final thoughts

Dammit, just as I was re-reading and re-editing this post for the 408th time I glanced away and saw a tweet from Netlify where they’re pointing out a Laravel-based static site generator from Tighten called Jigsaw..

I might need to migrate to that.