Skip to content

Importing Content

Ned Zimmerman edited this page Sep 5, 2019 · 1 revision

To import blog posts from the legacy platform.coop site, we use this WP-CLI package: https://github.com/dirtsimple/postmark

Installation

Ensure that your server or development environment has the following dependencies installed:

Run:

wp package install dirtsimple/postmark

File Preparation

The importer supports Markdown files with YAML front matter. Front matter keys need to be uppercased for the importer, which means you need to adjust Statamic's front matter keys to match the following:

- author: trebor
+ Author: trebor
- title: ​Platform Coops Looking for the Next Steps
+ Title: ​Platform Coops Looking for the Next Steps
+ Date: August 2, 2017

Note that the date field must be added. Other fields, including featured and meta images, will be ignored, so images must be uploaded manually after the post has been imported. If there is a Twitter handle field in the file's front matter, you need to enclose it in quotes:

- twitter_creator: @trebors
+ twitter_creator: '@trebors'

The file name (minus extension) will be used for the post's URL slug.

Usage

The importer can be used in two ways.

Single File Import

To import a single Markdown file, run:

wp postmark sync filename.md

Folder Import

To import a folder of Markdown files, run:

wp postmark tree folder/

Updating

Once a post or a folder of posts has been imported for the first time, running the import command again will update the content in WordPress with any changes that have been made. This can be helpful for tweaking content that has already been imported without navigating into the WordPress dashboard. It can also overwrite things to be careful!

Clone this wiki locally