This is a four-part blog post, the first covering why I moved to Hugo. Part two covers the hosting. Part three covers the Hugo deployment pipeline to Amazon S3. And the last part covers some of the benefits in terms of speed and security.
These posts are not intended as walkthrough on how to do it yourself, but simply sharing my experience hoping to impart some useful knowledge along the way.
WordPress is pretty easy to use, and there are plenty of plugins allowing you to do pretty much anything. However, the numerous WordPress upgrades and countless security flaws were making me feel it was time to abandon WordPress for a static site.
Nothing performs as good as a static site. Caching gets much easier, performance goes up, and are far more secure.
Static sites can be hosted anywhere, including GitHub Pages, Aerobatic, Amazon S3, Heroku, Google Cloud Storage, Surge, Netlify and more, and work well with CDNs. They run without dependencies on expensive runtimes like PHP and without dependencies on any databases. I’ve been using Digital Ocean Cloud hosting for the last 2 years. $5/mo is not that expensive, but solutions like GitHub Pages or Aerobatic are free and your site is hosted directly from your Git repositories, making it super easy to publish and work offline. Just edit, push, and your changes are live.
The static site generators
I wanted one that was easy to use and quick to compile the site for updates.
In the end, I have chosen Hugo.
Well, for two reasons:
It’s super fast.
It’s just a single executable with no external dependencies.
$ brew install hugo
The first step in this process was to migrate my comments to Disqus. It’s simply the simplest choice due to its ability to quickly integrate with WordPress and then continue to function on a static site.
I installed the WordPress Disqus Plugin, and it seamlessly integrated into my site and imported the comments into Disqus.
Now that all comments are secure on Disqus, the next step is to import the posts from WordPress.
This revealed to be by far the most challenging part of the process.
I tried two different tools – wordpress-to-hugo-exporter and Exitwp. While the rendered output from the former was good, the content of the Markdown files was mostly the same HTML used on WordPress posts. On the other hand, Exitwp’s generated files were pure Markdown, however the indentation was wrong, breaking the content rendering.
In the end I choose Exitwp simply because it was easier to format the Markdown files than cleanup the HTML mess generated by wordpress-to-hugo-exporter.
Importing WordPress posts into Hugo with Exitwp is a three steps task:
Export WordPress using the WordPress exporter under
Exportin WordPress admin and place the XML file inside the
wordpress-xmldirectory of Exitwp.
Run the converter by typing
python exitwp.pyin the console from the directory of Exitwp.
Copy the posts from Exitwp’s
Setting up the new system was a bit more work than I expected, but I definitely think the effort was worthwhile.
I’m happy that I’m in complete control of the stack for my blog. Using WordPress always made me a bit scared – performance issues, database corruption, and security holes were always on my mind. Plus, I hated the idea of my content being stuck in a database somewhere.
I do most of my writing in Markdown or Asciidoc these days, so having my site content in one of those formats and versioned in a Git repository was the idea that most appealed to me. No matter what happens, I’ll always have easy access to that content.