Migration from WordPress to Hugo
Recently, I made a big change on my blog. I migrated it’s content from WordPress to Hugo.
Why I migrated in a first place
There are a few reasons why I wanted to change WordPress as my CMS system. Let’s name them.
- WordPress needs hight maintenance. I must regularly update plugins, theme, and WordPress itself. This was really painful. And I don’t want to omit that, as it can lead to potential vulnerabilities, and my blog could get hacked because of that.
- The editor. Some time ago WordPress changed its visual editor. And for me the post creation became unpleasant, so eventually I’ve created new posts one in a quarter or even less often. That’s unacceptable because I want to share my experience and knowledge on my blog.
- Slowness. My site is simple, it contains only text and a few images. Loading times should not be a problem you say? That’s what I think also. But because WordPress is such a big system, it uses database to keep its content. And every time somebody is entering the page, WordPress needs to go to the database, read the content, and then serve it to the visitor. And that operation takes time. I use the caching plugin, but there are a few problems with it. Firstly, maintenance (look at the first point). The second thing is that the result of caching is not so great. The site is faster, also thanks to the great Cloudflare service. But it’s not even near to be blazingly fast.
So I decided I need to change.
WordPress alternative - Ghost
The first alternative that attracted me was Ghost. It is a lightweight CMS, and it uses markdown in its editor. I tried it, and must say it is a great WordPress alternative. Fast, easy to use, and gives you extra features (eg. newsletter). But here comes the problem, it costs $29 a month. For the features that it comes with it’s not a lot, for a business site, let’s say. But I run my blog as a hobbyist. It’s not producing me money (not directly). And it’s just too much for me to pay almost 30 bucks monthly to run my blog. I thought about hosting it on some hosting, the DigitalOcean for example. It’s cheaper than Ghost Pro, but not cheap for this project.
Static site generators
The benefits? Speed. this is plain HTML, with no backend, so can be loaded fast. And on top of that can be cached in CDN (I use Cloudflare for that). Here you can read the speed comparison between Hugo and WordPress.
Security. There are no plugins, backend, etc. to be worried about.
Writing experience. You are creating markdown files that are then converted to plain HTML sites.
The maintenance. Yes, it is still there. I’ve created the Github action, and must fix it if it broke. More on that later. I’ve setup the Cloudflare. But it was one-time setup, which I’ve done to my WordPress also.
Which static site generator did I use
I choose Hugo. It’s fast, simple to use, and has a great community. I cannot recommend it highly enough. The other popular alternative is Jekyll. But I like the Hugo workflow more.
Making the switch
When I decided that I want to move to Hugo, I decided also to keep only my English post content. The newest articles I’ve written was in English anyways, because I wanted to spread the knowledge more broadly, and not only close to the Polish community.
To transfer my posts from WordPress to markdown I used the tool created by Radek Maziarka, and described on his blog post about switching to Hugo. Go check it out.
I spend a lot of time searching for the right theme for my blog. I decided to go with Onepress. It needed a few fixes here and there, but it’s a great theme.
As I said earlier I didn’t want to spend a lot of money to host my blog. The static sites are simple, they can be hosted cheap. And when I say cheap I mean for free. Yes, you’ve heard it correctly. To host my blog I use Github pages, in conjunction with Cloudflare’s cache and CDN. That way the site is really fast to load.
I keep all the blog files on the repo on my Github. Also the repo is needed for the Github pages.
But I won’t be myself if I won’t automate the publishing process. So I write the blog post on my PC using VS Code. I commit the files to my blog repo. On push event, the Github action is fired up. It generates the static files, minifies the images, and uploads them automatically to the Github pages repo. After that the action is going to the Cloudflare using the API, and is asking to purge the cache. That way the new content is cached in Cloudflare. If you want to see my publishing GitHub action, and want me to describe it let me know in the comments section.
Setting up the whole thing took me about 2 evenings, and for now I am really happy about how it turned out.