If you’re just coming here for the solution, and don’t want to read the backstory about how I came up with the solution, I understand. :)
Click here to skip to the solution.
Recently I helped convert someone’s main blog from Ghost, back to WordPress.
While WordPress makes it easy to export in any format (so that you can easily import your entries into another blog engine), Ghost… does not.
While Ghost certainly does have an “export” tool, it exports in JSON format. JSON format is definitely preferable to XML, but no matter what, I could not find a way to import these entries into WordPress.
I searched through the plugin library–nothing was devoted to allowing an import through Ghost.
I furiously Googled–weirdly enough, any entries I could find about converting Ghost’s output to something that WordPress could import were all years old (and thus none of the solutions presented worked anymore, because I imagine Ghost’s export format had slightly changed.)
So, I decided to make my own.
The solution is on Gitlab — just download the Powershell script (the .ps1 file) and run it on the command-line, passing one parameter of “jsonFile”, which is the path to the Ghost export.
Then, you’ll need a plugin to import the new CSV file to WordPress — I used the “WP All-Import” plugin. It seemed to be well maintained, and unlike many other plugins, it didn’t require you to pay for it.
That’s it! I built it in Powershell, because A) I can make quick scripts very quickly in Powershell, and I was frustrated by this point, B) Powershell has very good native CSV and file format conversion abilities, and C) Powershell can now run on any platform (Linux and MacOS included).
If you’re running this script on Windows, you already have Powershell installed, but if you’re running it on any other system, the link to install Powershell will also be below.
I only had posts with single tags to test against, so my script is only designed to get one tag for each post for the new CSV-formatted entries.
Ghost’s JSON format for tags was… bad. I don’t know why it was the way that it was. With every other type of metadata you’d need associated with a post, their JSON has that data in the “post” object, but with tags, they’re in a completely different other place, and only associated to posts through a series of IDs. It’s weird.
Either way, if you come up with a solution to that, feel free to fork the project! (Or just suggest a pull request.)
Also, I’d like to eventually re-code this into Python, just because more computers probably use it by now!
- Ghost to WordPress Exporter: https://gitlab.com/M-D-M/ghost-to-wordpress-data-conversion
- WP All-Import Plugin: https://wordpress.org/plugins/wp-all-import/
- Powershell Installation: https://github.com/PowerShell/PowerShell