Skip to content

A node.js utility to convert the XML data exported from Wordpress into the format that contentstack-import utility can use to import content in Contentstack.

Notifications You must be signed in to change notification settings

contentstack/wordpress-xml-to-contentstack-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wordpress-xml-to-contentstack-converter

Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content.

This project (export script) allows you to export content from WordPress into an XML file and prepare it to be imported into Contentstack. Using this project you can easily export WordPress Users (authors), Categories, Media (assets), and Posts and convert them into a format suitable to be imported into Contentstack.

Setup and installation

  1. Download this project and run the command given below in a terminal:

    npm install

    This command will install the required node modules on your system.

  2. Export WordPress content into an XML file from the WordPress admin panel.

  3. Pass the absolute path of the file to the 'xml_filename' key in the config file.

Export modules

After performing the above steps, you need to export modules. You can either add all modules or only specific modules to suit your requirements.

Export all modules

Run the command given below to export all the modules:

  npm run export

This command will extract data of authors, assets, categories, and posts from the downloaded XML file and convert them in JSON files that is supported in Contentstack. These files are stored in the path mentioned in the 'data' key in the 'config/index.js' file.

Export specific module

Run the command given below to export specific modules:

  npm run export <<module name>>

The sequence of modules to be exported can be as follows:

  1. assets
  2. authors
  3. categories
  4. posts

Export specific modules via ID

Modules that you wish to export separately or those that have failed to export (modules are recorded in the error log or in the failed.json file) can be installed with the help of their IDs. These IDs will be stored as comma-separated values in a text file. Now, to export the modules, you need to provide the absolute path of the file that stores the IDs, when running the following command in a terminal:

  npm run export <<module name>> <<absolute_path_of_the_file>>

However, if you wish to export the 'categories' module, you need to provide the absolute path of the file that stores the slugs of all the categories (the slugs are stored as comma-separated values in the file), when running the following command in a terminal:

  npm run export <<module name>> <<absolute_path_of_the_file (slug for category)>>

Log

You can find the logs of the export process under libs/utils/logs. The files included are 'success' and 'error'. Successfully run processes are recorded under 'success' and the errors under 'errors'.

The logs for failed Media(assets) are recorded in 'wp_failed.json' and is stored under the 'master' folder located where your exported data resides.

Import content

Copy the 'contenttype' folder from your project and paste it in the path mentioned in the 'data' key within the 'config/index.js' file. The 'contentType' folder consist of the basic schema of content types which will help you to migrate your data.

Now, run the contentstack-importer script to import the content to Contentstack.

Known issues

  1. The internal links will not be updated.
  2. There is no provision to migrate authors' profile pictures or their social profile details, comments on posts, and pages.
  3. The author count in XML and MySQL export files are different.
  4. In XML-based export process, if the version of WordPress is lower than 4, the category description and parent details will be absent.
  5. Only published posts will be migrated.

License

This project is covered under MIT license.

About

A node.js utility to convert the XML data exported from Wordpress into the format that contentstack-import utility can use to import content in Contentstack.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published