Migrating Our Blogs from WordPress to Ghost
We used WordPress for years; really, years. In fact, as of this writing we still have a couple blogs running on WP. However, I just never really enjoyed using WordPress. I mean, in the first year or so, it was amazing. It was mostly because blogging was new to me. Once I wrote for a while, I started realizing there was so much driving me crazy about the platform. This article will not win any friends, I'm sure. WordPress is "top dog" after all.
Control Freeq
As a developer, I tend to want more control over the output of my websites than most. So, that translates to producing my own WP theme. Yeah. What a huge pain that is to do from scratch. Even if you can get beyond that or borrow from an existing theme to start with (child themes are a thing), I find the whole thing clunky and tedious. From the post loop all the way to the metadata mechanism, it feels very...legacy.
WordPress is marketed as a content management system (CMS). This is part of the problem. It tries to do too much. At first, it was simply for blogging. Now, it's a dumping ground for so many things. Did you know you can setup e-commerce in WordPress? Yep, and you will likely be violating PCI compliance or at least putting your users' data at risk in some way.
Legacy for the Sake of Compatibility
WordPress is old. That's no excuse for continuing to do something a certain way because it's always been done that way. The framework still uses global functions. I won't argue about procedural vs object-oriented programming (OOP). However, if the language supports some mechanism for modularity, use it. It's not ideal like a module system, but PHP does have namespaces at least. Regardless, the language has leaned toward OOP for years now, yet WordPress has yet to make the leap.
WordPress also makes an attempt at events by checking for the existence of key functions in your theme by name. It could utilize interfaces as a means for event handling in themes instead. That way, a function name is not all the system looks for; it can also guarantee its signature.
I am really not a huge fan of PHP either. There, I said it. Let's move on!
Ghost in the Machine
I went in search of a publishing platform, ideally built with Node.js or some headless option with an "easy button" for publishing securely. Just publishing; not a CMS (or at least not a complex one). Data is my thing, so I created a spreadsheet to compare the software I researched. In the end, I settled on Ghost.
Migrating from WordPress to Ghost
There is a WordPress plugin the Ghost team maintains for exporting your blog data in a format you can import to Ghost. We have a lot of data on a couple of our blogs. The process was not entirely seamless. I do think most people will not have issues though. Honestly, most of the problems are due to how WordPress stores data.
So, I wrote a tool to "fix" all the issues I encountered. With several blogs to convert, the effort was worth it. The biggest issue is the fact that WordPress stores absolute URLs when you link to other articles on the same blog. Even if you supply a root-relative URL, the freaking thing converts it to absolute (and with the scheme even). Ghost struggled with this some too. I get why it's a thing, especially for RSS/Atom feeds, but it can be done properly with root-relative URLs that don't need to be massively found/replaced if you change your blog's domain. Image URLs fall into a similar category in need of correcting.
The tool still needs some cleaning up, and it so desperately needs tests. However, I think it's best to put FixWordPressContent on GitHub regardless.