npm i @tryghost/mg-wp-api


Export content using the WordPress JSON API, and generate a `zip` file you can import into a Ghost installation.

by TryGhost

0.7.12 (see all)License:MITTypeScript:Not Found
npm i @tryghost/mg-wp-api

Migrate WP Api

Export content using the WordPress JSON API, and generate a zip file you can import into a Ghost installation.


To install the CLI, which is required for the Usage commands below:

npm install --global @tryghost/migrate

To use this package in your own project:

npm install @tryghost/mg-wp-api --save


yarn add @tryghost/mg-wp-api


To run an absolute basic WordPress migration, the required command is this:

migrate wp-api <url>

It's possible to pass more options, in order to achieve a better migration file for Ghost:

  • -V --verbose
    • Show verbose output
    • bool - default: false
  • --zip
    • Create a zip file
    • bool - default: true
  • -s --scrape
    • Configure scraping tasks
    • string - default: all
    • Choices: all, img, web, media, none
  • --size_limit
    • number - default: false
    • Media files larger than this size (defined in MB [i.e. 5]) will be flagged as oversize
  • -I --info
    • bool - default: false
    • Show initalisation info only
  • -b --batch
    • number - default: 0
    • Batch number to run (defaults to running all)
  • -l --limit
    • number - default: 15
    • Number of items fetched in a batch i.e. batch size
  • -a --auth
    • string - default: null
    • Provide a user and password to authenticate the WordPress API (:)
  • -u --users
    • string - default: null
    • Provide a JSON file with users. Contents should be a JSON array of objects that match the format returned by the Wordpress API, including the following keys: "id", "slug", "name", "description", "email" and "url".
  • --tags
    • boolean - default: true
    • Set to false if you don't want to import WordPress tags, only categories
  • --addTag
    • string - default: null
    • Provide a tag slug which should be added to every post in this migration
  • --featureImage
    • Change which value is used as the feature image
    • string - default: featuredmedia
    • Choices: featuredmedia, og:image, none
  • --excerptSelector
    • string - default: null
    • Pass in a valid selector to grab a custom excerpt from the post content, e. g. h2.excerpt
  • --datedPermalinks
    • Set the dated permalink structure
    • string - default: none
    • Choices: none, '/yyyy/mm/', '/yyyy/mm/dd/'
  • --cpt
    • A comma-separated list of custom post type slugs e.g. resources,newsletters
    • string - default: null
  • --fallBackHTMLCard
    • Fall back to convert to HTMLCard, if standard Mobiledoc convert fails
    • bool - default: false
  • --trustSelfSignedCert
    • Trust self-signed certificates (such as for local installs)
    • bool - default: false

A more realistic command for a WordPress migration looks like this:

migrate wp-api https://example.com --auth person:pa55w0rd --addTag 'From old site' --limit 10 --batch 5

This will fetch the newest 50 posts, in 5 batches of 10, collect real author data including email addresses), and add the tag 'From old site'.

migrate wp-api https://example.com --scrape img web

This will fetch all posts, and only scrape image & web meta data


This is a mono repository, managed with lerna.

Follow the instructions for the top-level repo.

  1. git clone this repo & cd into it as usual
  2. Run yarn to install top-level dependencies.


To run a local development copy, cd into this directory, and use yarn dev instead of migrate like so:

yarn dev wp-api <url>


  • yarn lint run just eslint
  • yarn test run lint and tests

Copyright & License

Copyright (c) 2013-2022 Ghost Foundation - Released under the MIT license.



GitHub Stars



5mos ago








4d ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

No reviews found
Be the first to rate