Migrate From WordPress to Ghost CMS: Because Ghost Migration Plugin Isn’t Enough

Rahmat Ramadhan Irianto
Geek Culture
Published in
5 min readApr 18, 2021

After I created an Article about Install Ghost 4.0 on Amazon Lightsail Using Bitnami With S3 Integration and Mailgun

I received an email from a new client about helping him migrate his Community News Website using WordPress to Ghost CMS.

One of the reasons why he wanted to migrate to Ghost CMS because the member subscription feature on Ghost CMS is powerful.

He had thousands of data and a hundred thousand visitors per day. And Migrating WordPress to Ghost CMS could be painful because of it.

The migration article on Google about migrating from WordPress to ghost cms might be only working for a WordPress website with a small of data with a standard plugin installed.

Trusted me, I tried many of the available solutions on google about how to migrate WordPress to Ghost CMS, and none of them work.

Ghost CMS migration plugins also won’t work if you have an installed plugin integrated with your WordPress posts.

Let me share with you the problem I faced and the way I solved it.

1. Critical error on ghost export

“There has been a critical error on this website. Please check your site admin email inbox for instructions. Learn more about troubleshooting WordPress.”

This not only about the memory size limit, max body size, or timeout issues from PHP config or WordPress config. It’s because of the library behavior that requires a huge memory, while my client has limited memory resources.

Solved

I was able to fix this by installing the WordPress plugin All-in-One WP Migration and export data for 21GB posts and images.

And after that, I install WordPress on my local system using Docker, restore the data that has been exported by All-in-One WP Migration in my local, and then using the Ghost plugin to convert the data to be able to use in Ghost CMS.

Docker helps me to save time and effort. You can follow the docker-compose WordPress tutorial here, or you can use the docker-composer.yml I used before from my public gist.

2. 504 gateway timeout ghost cms

After I successfully back up and restore the data from the server to my local system. I faced an error when I tried to import the Ghost export plugin from the ghost website.

If I investigate, I found that It happens because the JSON structure is invalid. The export result left an invalid structure key.

So, we have two options to fix these issues.
1. By refining the JSON file using an automated script like https://github.com/hughrun/ghost-to-wp

2. Creating the script to insert the data using Ghost Content API and Admin API.

I choose the second option because I wanted to make sure that everything is working as I expected.

Creating Content API and Admin API

One of the things that I really like about Ghost CMS is its headless feature. We can make any integration we want just by creating API integration.

Just go to Integration -> Add Custom Integration

Create integration name Content & Admin API

We will use these API credentials to load posts from our backup and create posts on Ghost CMS.

Creating Python Script to restore the content using Ghost CMS Admin API

We basically create our own script to restore our posts from WordPress to Ghost CMS. Don’t forget to install the dependencies.

Replace this with your credentials

CONTENT_API = "<YOUR CONTENT API>"
ADMIN_API = "<YOUR ADMIN API>"
API_URL = "<URL ENDPOINT>"
JSON_PATH = "<YOUR JSON PATH>"

Make sure the path file to JSON is correct. It’s better to create a new directory and place the script in the same directory with a JSON file. Then just run the script.

Restore The Image

To restore the image, we can upload the image that we download using All-in-One WP. Upload to directory /ghost/content/images by using SCP or SFTP protocol.

Creating Python Script To Restore The Image

Since I don’t pick the backup of the images, I need to create a script to download images from the previous website. Basically, we still have the WordPress version live before we point the main domain to the new website (Ghost CMS version).

I uploaded the script on /ghost/content/images directory. And run the script from there. I actually want to use Ghost Admin API to upload the image, but unfortunately, It doesn’t work. So many issues about the image API, but none of them fix by Ghost.

Make sure you also upload the JSON file to /ghost/content/images, Because the script will load the JSON file and refine the path, then download the image.

After that, we point the main domain to our new website with the Ghost CMS version. And we finally successfully migrate the WordPress website to Ghost CMS.

I know that we can create a script to shortcut the process. For this time, I would like to break it down so we can see every step and process required to migrate the website to Ghost CMS.

I know it requires technical stuff, but if you are a non-technical guy, you can drop me a message by email.

I hope this helps! Please give me some feedback!

--

--

Rahmat Ramadhan Irianto
Geek Culture

I’m a Python & Js Enthusiast. @BlockchainSpace BI Solution Architect. This is about my dev journal #Github https://github.com/rririanto