Kirby/JSON Sanity Content Migration
(2022-06-13T21:13:00.000Z)
For the relaunch of one of our clients we switched the content management system from Kirby to Sanity. In our case the old CMS was still running on Kirby 2 which does not provide any kind of API.
Our approach was to generate JSON with the necessary content structure from Kirby and a node.js script which would download all content/images and use the Sanity JavaScript Client to upload these to the new CMS.
In our case we had to process projects with simple text and an image gallery from a portfolio website. The script consists of several async functions to
- Create the Sanity document
- Fill in all basic information (Title, Text)
- Download all images from the project
- Upload all images to Sanity
- Connect the uploaded images with the image gallery/array
The Script
You can find the a sample setup with Kirby and Sanity example, plus the script in our GitHub Repo.