Export and migrate WordPress to Ghost

Photo of author
Written By Jan Reilink

Windows Server system administrator & enthusiast.

A little while ago I installed Ghost on IIS, along with the required Node.js and iisnode module. All in an isolated test environment, in which Ghost runs as a production site only. Now I wanted migrate from WordPress to Ghost, but failed. Here’s the write up.

Export WordPress content into a JSON format

Migrate from WordPress to Ghost and import posts from wordPress into Ghost, how to.

There are two ways to export your WordPress blog content into Ghosts JSON format:

  1. the Export to Ghost plugin
  2. wp2ghost, which will convert WordPress XML exports (WXR) to the Ghost JSON format

I tried both and both produced a JSON file, so that’s good.

Protip: format your WordPress JSON export file

The produced JSON export file is one long string, which makes it really difficult to read (and fix errors). I decided to format my JSON file for readability. With python json.tool:

$ cat wp2ghost_export_1402927865.json | python -mjson.tool > wp2ghost.json

Now you can actually read the contents of your JSON file and fix errors later on when they occur (they will…).

JSONLint – The JSON Validator

JSONLint.com is an online tool to validate your JSON file. JSONLint is a validator and reformatter for JSON, a lightweight data-interchange format.

It’s a great aid for when you run into error messages such as:

{"error":"Failed to parse the import JSON file"}
Code language: JSON / JSON with Comments (json)

Import WordPress content into Ghost

To import your WordPress content into Ghost, you need to visit your the Ghost debug tools page at http://www.example.com/ghost/debug. Select the file and press IMPORT.

If all goes well, your WordPress content is imported into Ghost. It didn’t go well on my site… A little pop-up provided only the error message:

A problem was encountered while importing new content to your blog. Error: unknown

and unfortunately iisnode didn’t log more information within its log directory. I tried again, and I first enabled my Chrome Developer Tool (function key F12). The Network tab displayed all requests and showed an HTTP 500 Internal Server Error on the import, but nothing more.

Since I host on IIS, I enabled IIS Detailed Errors and tried again. Now the response contained a real error message:

{"error":"Value in [posts.title] exceeds maximum length of 150 characters.<br>Value in [tags.description] exceeds maximum length of 200 characters."}
Code language: JSON / JSON with Comments (json)

Praising myself for making my JSON file more readable, I grepped the title: grep \"title\" wp2ghost.json and found one title longer than 150 characters. I couldn’t find a long tags description though, so I tried again.

This resulted in an error again:

{"error":"Value in [tags.slug] exceeds maximum length of 150 characters."}

After fixing this error too (e.g, shorten the slug), I could successfully import my WordPress content into Ghost. So I guess there was no problem with the tags.description.


Did you like: Export and migrate WordPress to Ghost

Then please, take a second to support Sysadmins of the North and donate!

Your generosity helps pay for the ongoing costs associated with running this website like coffee, hosting services, library mirrors, domain renewals, time for article research, and coffee, just to name a few.



Hi! Join the discussion, leave a reply!