Moving from WordPress to Hexo
Beware this content is over 2 years old and considered stale. It may no longer be accurate and/or reflect the understanding of the author but remains here for reference only. Please keep this in mind as you use this content.
Over the past few days I’ve been slowing migrating my small collection of posts I’ve accumulated over the past 8 years (or so) to Hexo from WordPress. I thought I would commemorate the occasion with a new post.
I’ve been using WordPress for a number of years now to fulfill a range of purposes, from basic blog platform to the foundation of a bespoke CMS supporting a commercial website.
It always fulfills the blog requirement really well and for everything else you really need to be more familiar with the internals to get the framework to bend to your will. However, the main draw for WordPress is that for non-technical users, it has one of the friendliest administration interfaces of any Open Source CMS_-like_ tool I’ve seen.
The main downside is the maintenance and upkeep. Seeing as WordPress is so popular it’s a regular target for exploits and even with automatic upgrades getting better and better, they can be a chore. Especially, if you don’t blog as often (like I do) then the only time you’re interacting with your website is just to install another security update.
So, I was after something that was more low maintenance.
I’ve also been interested in the numerous blog frameworks that generated static sites and allowed authoring in GitHub Flavored Markdown so that I could concentrate on the content and not get distracted by design.
After looking through the documentation for installing Hexo and reviewing some of the source code, I realised just how modular it is.
The Hexo team also provided a much of migration tools and of course, there was one for WordPress. You’ll need to perform an export of your current WordPress blog to extract all your content (posts, pages, comments etc.) as an XML file in the WXR (WordPress eXtended RSS) format
Most themes also come with support for hosted commenting systems like Disqus so you can use that same WXR file to import all your comments. This is only really suitable to retain comments for reference, they aren’t really configurable or editable after you import them so bare that in mind. Just make sure that each user has a unique email address otherwise the import will treat them all as the same user.
The only problem remained importing lots of very old posts. Instead of just deleting them, I created a plugin using the Hexo filter API. It allows you to hook into the process of building posts.
I created an outdated disclaimer configurable from the main
You’ll need to create a
scripts directory in the root directory at the same level as the main