Migrating FROM Ghost TO WordPress

So, after running Ghost for 8-9 months on this blog and trying to convince myself it’s the right thing to do; I’m moving back to WordPress.

I love the simplicity and sheer speed of Ghost, and am now a definite convert to writing content using Markdown. However, a continual source of frustration is the limited amount of 3rd party support available for the platform – especially in terms of themes – and the limited ability to quickly customise content; build custom lists/galleries etc, or easily re-use content you have already posted in different ways.

This is, of course, all perfectly possible if you opt to design & build your own custom theme, or write the necessary JS to pull out & present content in exactly the way you want. However, working with web technologies every day, the last thing I want to be doing on the rare occasion I actually have time to write something is needing to dive into the site’s codebase to add a feature, change a menu or tweak something.
As much as it pains me to say this, I’ve reached the conclusion that the simplest option is to move the blog back to WordPress for the moment. Ghost has been fun, but it just takes too much time & effort to do anything with it it other than posting articles. Creating anything other than a standard post is just too time consuming at the moment.

WordPress isn’t without its flaws of course, and most of the stuff I commented on back in this post when I first moved to Ghost still applies. It does however have a significent edge in terms of flexibility, and for all the good reasons outlined in a great post by Jeff Chandler on WPTavern I suspect WP will retain its lead for some time to come.

We’ll see how it goes, and I’ll endevour to keep this post updated with any more migration issues as I find them.

So, how do you migrate from Ghost to WordPress

Unlike moving from WordPress to Ghost, at the moment there doesn’t seem to be a usable Ghost import plugin for WordPress – whereas there are plenty of Ghost exporters for WP. So, it’s a bit of a manual process, but does seem to be possible.

I’m glossing over setting up WordPress and getting an empty website up and running into which you can import your posts. If you’re reading this, and have a blog running on Ghost, I’m going to assume you can probably figure that bit out. Google might be a good starting point otherwise.

Step 0 – Install WordPress & create a new blog / website

See above… I haven’t tried importing content into an existing site. It will probably work, but my recommendation would be to try everything out on a new test site that you won’t mind recreating a few times if it doesn’t go perfectly right first time.

Step 1 – Export content from Ghost

Ghost does however have a built-in tool to export its content to a JSON format file. Just login to your blog’s admin tool (eg. [your blog]/ghost, click Settings, Labs, and look for the Export button. This will generate and download a simple JSON file which contains all of your post text and content.

Step 2 – Convert JSON to CSV

I haven’t been able to find a way to easily import the Ghost JSON file directly into WordPress, so for now convert it into a CSV file first.

I used an ex-Google tool called OpenRefine to do this, but there are of course many other possible ways to tackle this. OpenRefine runs as a local web service, and once started is accessed using your browser. If you’d like to give it a go, head over to their download page and install the release that suits whatever you intend to run it on. I opted for the Mac version, but hopefully other platforms will be similar.

Once this has been installed, start the application and then open using your prefered web browser.

From OpenRefine’s start screen, create a new project by selecting your CSV file to upload and click “next”. Once uploaded, OpenRefine will parse your JSON file and display a preview of it.
To get started, you first need to indicate what element within your JSON file contains the data items (eg. posts) that you’re interested in processing. To do this, find the first “posts” entry and click just after the following “{“. This should select the posts and highlight them.

For completness, I also had “Trim leading and trailing whitespace” and “Parse cell text into..” options selected. Next, click the “Update Preview” button and with a little luck you should see a grid containing your Ghost posts.
If everything looks OK, click “Create Project” to process your data and move onto the next step.

At this point you can process the data file in many ways, add additional things into the data or summarise it to your heart’s content. However, all I needed to do to get the posts setup for WordPress was convert the date fields from “Unix” or “Epoc” dates to a normal format that WordPress can import.

To do this, scroll across the data until you find the CreatedAt or PublishedAt date columns. Click the header, select “Edit Cells” then “Transform” from the menu.

Select Jython as the Language, and paste in the code snippet below.

import time;
epochlong = int(float(value))/1000 ;

datetimestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(epochlong));
return datetimestamp

This should update the preview and show normal dates alongside their equivalent Epoc/Unix datetime stamps. Click OK when you’re happy with the result, and assuming you don’t need to change anything else, click the Export button at the top right, and pick “Comma Separated Value” from the menu. All being well, your browser should then start downloading a copy of your post data in CSV format.

Step 3 – Import to WordPress

First, you need to find and install a CSV import plugin for WordPress. I opted to try “WP Ultimate CSV Importer Plugin“, v3.6.75 at time of writing, which seems to do what I need it to.

With the plugin installed & activated, open it up from your WordPress admin panel, pick “Imports” and then “Posts” from its menu. Browse & find your freshly downloaded CSV file, and click “next” to get started. The plugin should then open your CSV, and display all the fields it can find in the file for you to map them onto the most appropriate equivalents in WordPress.

You can ignore the majority of Ghost specific data here to get going, focusing on the key information needed to create a post. For my setup, these fields were:

  • slug -> post_slug
  • html -> post_content
  • image -> featured_image
  • title -> post_title
  • status -> post_status
  • author -> post_author
  • publishedat -> postdate (you could also use created_at if that’s a better option for your posts)

Once done, click Next, increase the number of rows/posts per request to maybe 5, and click “Import Now” to start the process.

If everything works as it should, your Ghost posts should now be in WordPress as posts.

From this point, I simply needed to create new categories for posts and bulk-edit my posts to move them into the correct categories. I wasn’t using Tags in URLs on Ghost, so all my post titles/slug are the same as they were – removing the need to deal with lots of redirects to preserve search engine traffic.

Depending on how you were handling images in posts on Ghost, you might now need to copy your image library over to WordPress or check that images were imported correctly.

Next steps – finding time to do all the stuff I want to actually do with this site!

Similar Posts