- Clone this repo
- Set
const filename
inmigrate.js
to the path of your wordpress export xml file - Run
npm start
to log out the converted sanity documents in the terminal - Pipe the output to an import file by
npm start > myImportfile.ndjson
- Try to import the file with
sanity dataset import myImportfile.ndjson
in your Sanity project folder
Mostly probably there is additional content that this script doesn't migrate, however, it should cover the most usual patterns, so that you can build it out for your specific use case.
- This script reads the wordpress export XML file
- This example is based on the blog template schema
- There's a bug in
xml-stream
where it doesn't seem to emit errors - Debugging deserialization (
parseBody.js
) is easier with the script in/test
- Remember to add additional supported custom types to
/schemas/defaultSchema.js
- The HTML is sanitized, but most HTML tags are allowed (check
/lib/sanitizeHTML.js
)