{"id":13402459,"url":"https://github.com/storyblok/wordpress-importer","last_synced_at":"2025-07-21T20:37:57.785Z","repository":{"id":47215802,"uuid":"374644696","full_name":"storyblok/wordpress-importer","owner":"storyblok","description":"A simple script for migrating content from WordPress to Storyblok.","archived":false,"fork":false,"pushed_at":"2024-07-19T00:35:13.000Z","size":15,"stargazers_count":17,"open_issues_count":7,"forks_count":12,"subscribers_count":13,"default_branch":"main","last_synced_at":"2024-07-31T19:36:13.433Z","etag":null,"topics":["headless-cms","migration-tool","storyblok","wordpress"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/storyblok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-07T11:41:39.000Z","updated_at":"2023-11-07T22:44:11.000Z","dependencies_parsed_at":"2024-10-26T06:45:42.923Z","dependency_job_id":null,"html_url":"https://github.com/storyblok/wordpress-importer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/storyblok/wordpress-importer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storyblok%2Fwordpress-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storyblok%2Fwordpress-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storyblok%2Fwordpress-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storyblok%2Fwordpress-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/storyblok","download_url":"https://codeload.github.com/storyblok/wordpress-importer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/storyblok%2Fwordpress-importer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266375785,"owners_count":23919624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["headless-cms","migration-tool","storyblok","wordpress"],"created_at":"2024-07-30T19:01:16.316Z","updated_at":"2025-07-21T20:37:57.759Z","avatar_url":"https://github.com/storyblok.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\t\u003ca  href=\"https://www.storyblok.com?utm_source=github.com\u0026utm_medium=readme\u0026utm_campaign=wordpress-importer\"  align=\"center\"\u003e\n\t\t\u003cimg  src=\"https://a.storyblok.com/f/88751/1776x360/ffa245ed47/sb-wp-git-hero.png\"  alt=\"Storyblok Logo\"\u003e\n\t\u003c/a\u003e\n\t\u003ch1  align=\"center\"\u003eStoryblok WordPress importer\u003c/h1\u003e\n\t\u003cp  align=\"center\"\u003eA simple script for migrating content from WordPress to \u003ca href=\"https://www.storyblok.com?utm_source=github.com\u0026utm_medium=referral\u0026utm_campaign=wordpress-importer\"\u003eStoryblok\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://discord.gg/jKrbAMz\"\u003e\n   \u003cimg src=\"https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community\u0026style=appveyor\u0026logo=discord\u0026color=09b3af\"\u003e\n   \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/intent/follow?screen_name=storyblok\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor\u0026logo=twitter\" alt=\"Follow @Storyblok\" /\u003e\n  \u003c/a\u003e\u003cbr/\u003e\n  \u003ca href=\"https://app.storyblok.com/#!/signup?utm_source=github.com\u0026utm_medium=readme\u0026utm_campaign=wordpress-importer\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==\" alt=\"Follow @Storyblok\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## 🚀 Usage\n\n### Prerequisets\nThis script has been tested on WordPress v5 with API v2. WordPress REST API must be publicly available during the migration process as this script won't handle authentication.\nOn the \u003ca href=\"https://www.storyblok.com\" target=\"_blank\"\u003eStoryblok\u003c/a\u003e side you just need a space. In case the space is not an empty one, we recommend to test it before with a copy of the original space to make sure the migration process doesn't cause an issue to the existing content. \n\n### How to use\nTo use the script, just import it, initialise a new instance of the `Wp2Storyblok` class and run the `Wp2Storyblok.migrate()` method.\n\n```javascript\nimport {Wp2Storyblok} from './index.js'\n\nconst wp2storyblok = new Wp2Storyblok('http://yoursite.com/wp-json', {\n  token: 'storyblok-oauth-token',\n  space_id: 110836,\n  blocks_mapping: [\n    {\n      name: 'core/paragraph',\n      new_block_name: 'richtext',\n      schema_mapping: {\n        'attrs.content': 'content'\n      }\n    },\n    {\n      name: 'core/image',\n      new_block_name: 'image',\n      schema_mapping: {\n        'attrs.url': 'image'\n      }\n    }\n  ],\n  content_types: [\n    {\n      name: 'pages',\n      new_content_type: 'page',\n      folder: 'your-custom-folder',\n      taxonomies: [\n        {\n          name: 'categories',\n          field: 'categories',\n          type: 'value'\n        }\n      ],\n      schema_mapping: {\n        title: 'name',\n        '_links.wp:featuredmedia.0': 'content.preview_image',\n        content: {\n          field: 'content.body_items',\n          component: 'rich-text',\n          component_field: 'content',\n          categories: 'content.categories'\n        }\n      }\n    }\n  ]\n})\n\nwp2storyblok.migrate()\n```\n\n**Parameters**\n\n- `endpoint` String, The main endpoint for the WordPress REST API, without the `/wp/v2/` part\n- `settings` Object\n  - (`region` String, Optional, The region of your Storyblok space. Default is `eu`) \n  - `token` String, The oauth token for the management API that can be retrieved in the account section of https://app.storyblok.com\n  - `space_id` Integer, The id of your space\n  - `content_types` Array of Objects\n    - `name` String, The name of the content type in WordPress\n    - `new_content_type` String, The name of the content type in Storyblok\n    - `schema_mapping` Object, The mapping of the fields from WordPress to the fields in Storyblok. More info about the mapping [here](#fields-mapping)\n  - (`blocks_mapping` Array of Objects, Optional, More info [here](#wordpress-blocks-mapping))\n    - `name` String, The name of the block in WordPress\n    - (`new_block_name` String, Optional, The name of the component in Storyblok. If not set the original name of the component will be used)\n    - `schema_mapping` Object, The mapping of the fields from WordPress to the fields in Storyblok. More info about the mapping [here](#fields-mapping)\n  - (`taxonomies` Array of Objects, Optional, The taxonomies of the content type, More info [here](#importing-taxonomies))\n    - `name` String, The name of the taxonomy in WordPress\n    - `field` String, The name of the source field in WordPress\n    - (`type` String, Set to `value` to replace the taxonomy id with the slug of the taxonomy value. Set to `relationship` or leave empty in case you imported also the taxonomy entries as stories and you want to link the taxonomy entry with an option or multi-option field by UUID )\n  - (`folder` String, Optional, The full slug of the destination folder in Storyblok)\n\n#### Fields Mapping\nThe fields mapping object requires you to use the name of the field from WordPress as keys of the attributes and the name of the field in Storyblok as its value. You can also target subproperties and array elements using the dot notation.\n\n```json\n\"schema_mapping\": {\n  \"_links.wp:featuredmedia.0\": \"content.preview_image\"\n}\n```\nIn case you want a field to be migrated as content inside a nested block in a field in Storyblok, you can do that defining the target as an object with the following properties:\n\n- `field` String, The name of the field in Storyblok\n- `component` String, The name of the component you want to store inside the above field\n- `component_field` String, The name of the field inside the component where you want to migrate the content\n\n```json\n\"schema_mapping\": {\n  \"content\": {\n    \"field\": \"content.body_items\", \n    \"component\": \"rich-text\", \n    \"component_field\": \"content\" \n  }\n}\n```\n\n#### WordPress Blocks Mapping\nYou can import blocks created with Gutenber as components in Storyblok. To achieve this you need to install the [REST API blocks plugin](https://wordpress.org/plugins/rest-api-blocks/) and fill out the `blocks_mapping` property in the migration settings.\nYou need to create an array of objects where you specify the name of the block from Gutenberg (called `blockName` in the REST API), the name of the component in Storyblok and then the schema mapping in the same format as for the content types. \nThe blocks from Gutenberg are returned by the REST API inside the main object of an entry in a property called `blocks`. \n\n```json\n  {\n    \"name\": \"pages\",\n    \"new_content_type\": \"page\",\n    \"folder\": \"\",\n    \"schema_mapping\": {\n      \"title\": \"name\",\n      \"blocks\": \"content.body\"\n    },\n  },\n```\n\n#### Importing Taxonomies\nTaxonomies can be imported along with the other fields. You need to fill out the `taxonomies` settings in the settings of your `content_type` and the script will get the taxonomy value from WordPress instead of the taxonomy id and it will add it to your Stories in the field you chose. \n\n## 🔗 Related Links\n\n\n* **[How To Migrate From WordPress To A Headless CMS](https://www.smashingmagazine.com/2021/07/wordpress-headless-cms-storyblok/)**: In this article, we will look at when it makes sense to migrate from a monolithic project to a headless setup and the benefits that come with it. In addition to a step-by-step guide on how to migrate WordPress to Storyblok Headless CMS, the problems that will arise during the process and how to deal with them;  \n* **[Storyblok Technologies Hub](https://www.storyblok.com/technologies?utm_source=github.com\u0026utm_medium=referral\u0026utm_campaign=wordpress-importe)**: we prepared technology hubs so that you can find selected beginner tutorials, videos, boilerplates, and even cheatsheets all in one place.\n\n## ℹ️ More Resources\n\n### Support\n\n* Bugs or Feature Requests? [Submit an issue](../../issues/new);\n\n* Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).\n\n### Contributing\n\nPlease see our [contributing guidelines](https://github.com/storyblok/.github/blob/master/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com\u0026utm_medium=readme\u0026utm_campaign=wordpress-importer).\nThis project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ.\n\n### License\n\nThis repository is published under the [MIT](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoryblok%2Fwordpress-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoryblok%2Fwordpress-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoryblok%2Fwordpress-importer/lists"}