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. Then I wanted to migrate from WordPress to Ghost, but failed. Here's the write-up.
Export WordPress to Ghost's JSON format with a plugin or wp2ghost, pretty-print the JSON so you can read and fix it, and enable detailed errors to see why an import fails. In my case, post titles and tag slugs longer than 150 characters broke the import.
I originally wrote this post in 2014 for Ghost 0.x running on IIS with iisnode. The /ghost/debug import page and the import errors described here are from that Ghost version; current Ghost versions work differently.
Export WordPress content into a JSON format
Here is how to migrate from WordPress to Ghost and import your WordPress posts into Ghost. There are two ways to export your WordPress blog content into Ghost's JSON format:
- the Export to Ghost plugin
- wp2ghost, which converts 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's 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 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 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
Unfortunately iisnode didn't log more information in its log directory. I tried again, this time with Chrome Developer Tools open (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 titles with grep \"title\" wp2ghost.json and found one title longer than 150 characters. I couldn't find a long tag 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. shortening the slug), I could successfully import my WordPress content into Ghost. So I guess there was no problem with the tags.description after all.
Running Ghost on IIS with HTTPS? Read how I resolved a "Too many redirects" error with Ghost on IIS, and how to send email with Ghost using SMTP authentication and TLS encryption.