Migrating WordPress articles to Storyblok
Storyblok is the first headless CMS that works for developers & marketers alike.
In this tutorial, you'll learn how to migrate WordPress articles to Storyblok using the Storyblok WordPress Importer.
Why migrate to Storyblok?
While WordPress is open-source and widely used, it is a monolithic CMS that can become limiting as your business scales. Features like content planning, workflows, and omnichannel support are either unavailable or difficult to implement.
Storyblok, on the other hand, is a modular, headless CMS. Its powerful APIs give developers the freedom to use any tech stack, and its visual editor provides an enhanced editorial experience. With Storyblok, you can scale seamlessly without worrying about hosting, security, or infrastructure limitations.
Understanding the Storyblok WordPress Importer
The Storyblok WordPress Importer, created by Storyblok, simplifies the migration process. The script allows you to map WordPress API fields to Storyblok fields. For example:
Refer to the WordPress API documentation to understand the available fields.
Preparing for migration
- Create a Storyblok Account: Sign up here.
- Set Up a Storyblok Space: Learn how to create a space and design content schemas in the Getting Started Guide.
- Generate a Personal Access Token: Follow this guide to obtain your token.
Designing the content schema
Before migrating, we need to replicate the WordPress schema in Storyblok. If you're not familiar with Storyblok schema design, you can start here.
Once you're comfortable with it, let's create the following content schemas in Storyblok:
- Category (Content Type Block):
description
(Text)
- Author (Content Type Block):
bio
(Text)
- Post (Content Type Block):
featured_image
(Asset)excerpt
(Richtext)content
(Richtext)categories
(Multi-option References)author
(Single-option Reference)
Configure relationships so that articles can reference authors and categories.
Mapping WordPress content to Storyblok
- Clone the Storyblok WordPress Importer repository.
- Create a new file,
migrate.js
, and add the following code: In the code above, we are mapping all WordPress API properties to the corresponding fields we modeled in Storyblok. For example, in the WordPress API response, there is a field_links.wp:featuredmedia.0
, which has been mapped tofeatured_image
in Storyblok. We follow the same pattern for all other fields as well.You can also refer to the Storyblok MAPI docs if you want to dive deeper. - Run the script using:
- Verify the migrated content in your Storyblok space.
Best practices
- Take the opportunity to optimize your schema. Storyblok's dynamic API allows you to fetch only the required data, making it efficient.
- Name your fields meaningfully to reflect their purpose clearly.
- Consider what you actually need to migrate—for example, just news articles. This is a common scenario and allows you to design a more suitable content model for other sections of the site separately.