This tool assists users in migrating their Webflow content to Sanity. It fetches collections from Webflow and allows users to select which site and collection they wish to migrate. After selection, the tool maps Webflow items to a predefined Sanity schema, provided by the user, and uploads them to Sanity.
This code contains a demo mapping function for how to handle:
- Migrating images from Webflow to Sanity.
- Migrating files from Webflow to Sanity.
- Migrating Webflow Rich Text Content (HTML) to Sanity Block Content.
- Node.js
node-fetch
,axios
,readline
,@sanity/client
,@sanity/block-tools
,@sanity/schema
,jsdom
, anddotenv
npm packages.- Webflow API Key
- Sanity Project ID, Dataset Name, and Sanity Token
-
Clone the repository.
git clone <repository-url>
-
Navigate to the project directory.
cd path-to-directory
-
Install the required
npm
packages.npm install
-
Setup your environment variables:
Create a
.env
file in the root directory and populate it with your Webflow API Key, Sanity Project ID, Dataset Name, and Sanity Token.WEBFLOW_API_KEY=YOUR_WEBFLOW_API_KEY SANITY_PROJECT_ID=YOUR_SANITY_PROJECT_ID SANITY_DATASET=YOUR_SANITY_DATASET_NAME SANITY_TOKEN=YOUR_SANITY_TOKEN
-
Run the script.
node path-to-your-script.js
-
Follow the on-screen prompts to select a Webflow site and collection.
-
Wait for the content to be migrated. The tool will print progress messages as it processes each item.
- Fetch all Webflow sites associated with the provided API key.
- Allow users to select which site and collection they wish to migrate from Webflow.
- Map Webflow content to a predefined Sanity schema.
- Handle image and file uploads to Sanity.
- Report any errors that occur during the migration process.
- Ensure you have appropriate permissions for both Webflow and Sanity platforms.
- It's recommended to run a test migration on a smaller dataset or backup your Sanity dataset before performing a large-scale migration.
This project is licensed under the MIT License.