How I migrated Wordpress blog to Ghost

The process was pretty easy, but I hit some bumps on my way and I want to share my experieces with a hope that somebody would find it useful.

TL;DR Version

  1. You will need to take care of the images. There is no way at the moment to import images into Ghost.

  2. If your blog uses Disqus for comments and has permalinks in form of YYYY/MM/DD/slug then worry not. If you have some custom permalink settings for your Wordpress installation, then make sure you have some plan on how to handle comments (e.g. have file with old and new URL before starting the migration). If you use Wordpress comments then you have to change your permalink settins and then use Disqus to import your comments. After this you may proceed with migration and not worry about anything.

Verbose version

Basically, process of migration from Wordpress to Ghost consists of four steps:

  • Export content with help of official Wordpress to Ghost plugin
  • Preprocess json data file - change image links, rename tags
  • Import json preprocessed data file into Ghost
  • Post processing - review blog posts and fix markup where needed

While export and import are basically one click operations, exported data preprocessing takes most of the time, although it is still pretty easy with right tools applied.

Ghost provide their own Wordpress plugin which exports data in format that could be imported into Ghost blog without any further fiddling, but for real life scenarios we will need to handle the following issues:

  • Wordpress categories
  • Images and files
  • Comments

Categories

Ghost does not support categories, so we need to convert those to tags. I used Taxonomy Converter plugin to do the conversion.

Images and files

The Ghost export plugin does not export images – the exported post's markup contains absolute links to image files.

Wordpress stores media files in wp-content folder and the easiest solution would be just to copy this folder and its content over to the new location, but this, unfortunately, will not work.

Ghost is a NodeJs application and it processes requests for files based on defined routes and thee is no such route as "/wp-content" defined. Ghost has its own file folder for media uploads and I could put my files inside that folder, but I decided to use Amazon S3 storage service instead and leverage Amazon CloudFront feature to improve the overall performance of the site.

To make it all work, I opened the exported json file and applied search and replace trick to point all the images to my S3/CDN storage domain.

Comments

The latest available version of Ghost does not support comments and the team explicitly states that they expect users to use 3rd party systems like Disqus.

On my old site I already use Disqus for comments, so this should not be something to worry about. It only takes minutes to insert Disqus code into a post template.

And here is where things went bad

Unfortunately, my old blog uses permalink format which is {year}/{month}/{slug}, but Ghost generates dated permalink as {year}/{month}/{day}/{slug} and this effectively breaks links that have been indexed by search engines and Disqus will not be able to match existing comment threads to new urls without going trough their migration procedure.

The consequences

Migrating to a platform and changing links is sure way to lose indexed pages and this is what happened to me. On top of that, Disqus plugin started seeing blog posts as new pages and all the posts now have zero comments. While dropping out of search engine index for this non-profit opeation is bearable trouble because googlebot will reindex the entire site eventualy. Losing comments is the most painful experience I had during this migration.