Migrating This Blog from WordPress to Ghost — Headless, via the Admin API
Leaving WordPress for Ghost, almost entirely through APIs — and the sharp edges I hit.
I moved this blog from WordPress to Ghost by script. This post covers the tool, the import call, the login problem and the HTML conversion. It was Ghost 5 when I migrated. The site now runs Ghost 6.73, checked on 2026-10-28.
Export with @tryghost/migrate
npm install --global @tryghost/migrate
migrate wp-api --url https://example.com--pages and --posts default to true, so my original --pages true was redundant. --auth user:pass covers a protected WordPress API. --zip defaults to true.
The README states no Node version. I needed Node 22 or newer, because the tool uses node:sqlite, which first shipped in Node 22.5. On Node 20 it threw ERR_UNKNOWN_BUILTIN_MODULE.
Do not feed the zip to Ghost
The tool writes a zip. Do not import the zip. Extract ghost-import.json and POST it to:
/ghost/api/admin/db/When I fed the zip to Ghost, the import silently did nothing. Images copy separately into Ghost’s content folder.
That endpoint is not in the public Admin API list. It is undocumented and subject to change. Check it against your Ghost version before you rely on it.
Logging in from a script
Ghost 5 emails a sign-in code. With no SMTP configured, the session endpoint returned HTTP 500 for me. With 2FA on and a working mail setup, the session login returns 403 with User must verify session to login, and you send the code to PUT /admin/session/verify/.
I first wrote that I disabled staffDeviceVerification to get past this. It works:
security.staffDeviceVerification: falseor the environment form, security__staffDeviceVerification. It also removes the email 2FA option. Turn it back on once SMTP works.
A better route for scripts is an integration key, which avoids 2FA entirely. The key signs a JWT:
- algorithm HS256
kidset to the key idaudset to/admin/expno more than 5 minutes afteriat
You send it as Authorization: Ghost TOKEN. I now recommend this over turning verification off.
Editing posts: HTML and Lexical
I edit posts through the API with ?source=html. Ghost converts the HTML to Lexical, and the conversion is lossy. For a lossless copy, wrap the HTML in card markers:
<!--kg-card-begin: html-->
...
<!--kg-card-end: html-->Ghost then stores the block as an HTML card and leaves it alone. The tradeoff is that the visual editor shows a raw block.
Order of work
- Install the migrate tool on Node 22 or newer.
- Run
migrate wp-apiagainst the old site. - Extract
ghost-import.jsonfrom the zip. - Create an integration key in Ghost.
- POST the JSON to the import endpoint with a signed token.
- Copy images across.
- Spot check posts, then pages.