Exporting Wordpress to GravCMS


Overview

Wordpress, like GravCMS, is a PHP-based content management system. Unlike Grav, Wordpress requires a database to store its data. Grav uses the filesystm to store configuration and page data.

Wordpress does not natively offer an option to export its data in a format that Grav can easily use. In order to perform the export, you'll need the following:

  • A Wordpress site that you have administration rights to
  • WP-CLI installed on the server hosting the WP site
  • Composer installed on the server

Installation of wp2grav_exporter

I've written a wp-cli plugin that will do almost all of the heavy lifting for us called wp2grav_exporter.

  • Download the plugin from here.
  • Copy the files to the wp-content/plugins/wp2grav_exporter folder on the Wordpress server.
  • Log into the Wordpress server and navigate to the wp2grav_exporter folder.
  • At the command line, type in composer install to install the PHP dependencies of the plugin.

Exporting the WP Site

  • From the command line, type in wp wp2grav-FEATURE where FEATURE is:
    • users : Exports WP users to Grav account yaml files.
    • roles : Exports WP roles to Grav groups yaml file.
    • posts : Exports WP pages and posts to Grav pages markdown files.
    • post_types : Export WP page and post structure to a Grav theme, usable by the Grav admin plugin.
    • all : Iterates through all the above features.

Example: wp wp2grav-users will create a folder with a Grav account for each Wordpress user.

Migrating exported files

All exported files will be saved to the Wordpress's wp-content/uploads/ folder under user-DATE, where DATE is the current date. This folder can be drag-dropped into a Grav site's user folder. See the learn site for how to install Grav.

You'll need to change the Grav site theme to wordpress-export inside the user/config/system.yaml file:

pages:
  theme: wordpress-export

Previous