notes from a passionate developer





This is a personal blog. The opinions expressed here represent my own and not those of my employer, nor current or previous. All content is published "as is", without warranty of any kind and I don't take any responsibility and can't be liable for any claims, damages or other liabilities that might be caused by the content.

How to move from Wordpress.Com to Ghost.Org

If you have a custom install of Wordpress you can make use of a plugin to move your content from a Wordpress "blog" to a Ghost hosted blog. How-ever, the Wordpress as a service provider Wordpress.com does not allow this plugin. So, the idea is: using Docker, quickly create a local containerized Wordpress installation that you export your Wordpress.com blog contents to. From the local install, you then export to Ghost using the Ghost export plugin.

We will cover the following steps (most are just click, click...done):

  1. Host Wordpress in Docker
  2. Configure Wordpress
  3. Export from Wordpress.com
  4. Import to your local Wordpress
  5. Optional cleaning
  6. Produce a Ghost export
  7. Move the Images
  8. Enable syntax highlighting

Follow ups

  1. Issues after migrating from Wordpress.Com to Ghost.Org


SECURITY... The Setup below is just as simple as possible and I have no intentions in hosting my Wordpress installation publically, so I don't care about passwords etc.

CONTENT If you are not sure, a backup of contents at the target (where you write) is always good.

Not covered in this post

There are some basic stuff you also need to do, like fixing comment support and hooking in e.g. Google analytics.

Step 1 - Host Wordpress in Docker

First step is to get a MySQL database that the Wordpress installation can use.

docker run --name wordpressdb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -d mysql:5.7

Then we can continue getting a Wordpress container running, using the MySQL database.

docker run --name wordpress --link wordpressdb:mysql -p 8080:80 -v "$PWD/data":/var/www/html -d wordpress

It's important that you mount a host directory (sample $PWD/data) to the exported container directory /var/www/html. This is something we do so that we can access the images that will be imported from your public Wordpress, to your local install. They will be put in a folder called: wp-content/uploads.

Ensure the docker containers are running:

docker ps

If they are running, you should be able to access your Wordpress installation on your docker host IP combined with the exposed port above, e.g.:

Step 2 - Configure Wordpress

Well, I just picked "English" and provided the same username and blog title that I use on my public Wordpress.com as well at Ghost PRO.

Step 3 - Export from Wordpress.com

In your hosted Wordpress installations' dashboard/controlpanel, select:

Tools --> Export

then select what you want to export. I went with all contents.

Step 4 - Import to your local Wordpress

In your local Wordpress installation's dashboard/controlpanel, select:

Tools --> Import ---> Wordpress

If you don't have this option, you must install a plugin for it.

Step 5 - Optional cleaning

Before producing the Ghost export, you could do some cleaning. Like I had "clashes" between tag-names and category names in Wordpress, which caused my tags to get an ugly numeric suffix. Hence I removed all categories then went through and renamed some tags. I also deleted a bunch of drafts etc.

Step 6 - Produce a Ghost export

This process is well covered before, but basically:

  1. Install the Ghost export plugin
  2. Use it: Tools --> Export --> Export to Ghost.

Step 7 - Move the Images

I'm going to host my images at Ghost PRO, with a custom domain pointing to it, and will not be using a custom CDN. So in the exported Ghost JSON-file, I fixed the links pointing to my local Wordpress installation IP, to instead point to my custom domain instead.





The Images was then downloaded from my docker host (see Step 1 above) and then provided to the excellent and awesome staff at Ghost PRO using a ZIP-file. Please note, that the downML-plugin does not work for our needs, as it does not keep the folder structure with year/month.

Step 8 - Enable syntax highlighting

I'll not do this by customizing the theme, but instead, use the Code injection feature of Ghost and use highlightjs. Links to latest CDN hosted version, can be found here: https://highlightjs.org/download/

Pick a style sheet that gives the colourings you like and then configure the script. Check the demo page for styles and languages. Since I know what languages I will be using, I've configured the once I want the lib to support. You can skip that and let it support a multitude of languages.

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/github.min.css">  
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>  
        languages: [
            'html','css', 'js', 'javascript',
            'xml', 'json',

With this in place, you can write blocks like:

    public class Foo {
        public string Value { get; set; }

and get:

public class Foo {
    public string Value { get; set; }

The end

Haven't gone through all the posts yet, but so far it has played out well and I'm happy with moving to Ghost PRO instead of Wordpress.Com, as it feels: simpler, lighter and focuses on writing.


View Comments