Windows Server

Export and migrate WordPress to Ghost

Sharing is caring!

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.

Pro tip: 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 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"}

Import WordPress content into Ghost

To import your WordPress content into Ghost, you need to visit your the Ghost debug tools page at Select the file and press IMPORT.

This may interest you:   Fix "Could not establish trust relationship for the SSL/TLS secure channel" error

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."}

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.

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.