Preparing a Studio and schema types
2025-11-09

If you've completed the WordPress environment checks in the previous prerequisites section, let's get started right away. This time, we'll create the Studio environment for the CMS and prepare the content schema.

Creating a Project

First, proceed with creating a Sanity project. Execute the following command in the command line.

sh

Since this environment is already linked to your Sanity account, you will be prompted with questions about your organization.

Image

After a short while, the new environment will be created and accessible from the Sanity admin panel.

Image

Add an environment file

The created project currently contains embedded elements such as the Sanity Project ID. While this is unnecessary for individual or team work, since we are publishing sample code this time, we will make the following changes.

First, create a .env file as follows.

text

Next, we will modify two files that utilize the above values.

sanity.cli.ts
sanity.config.ts

You can now manage the Project ID as an environment variable.

Adding Schema Types

We will add definitions for content schemas to store WordPress content. This time, we will add four schema types.

Add content schema

First, add the schema for the page's content.

./schemaTypes/pageType.ts

Next, we'll add a schema for blog posts.

./schemaTypes/postType.ts

Add the tag schema.

./schemaTypes/tagType.ts

Add the category schema.

./schemaTypes/categoryType.ts

Add the author schema.

./schemaTypes/authorType.ts

This completes the addition of the schema for storing data retrieved from WordPress.

Schema Customization

In Sanity, the rich text content managed in WordPress will be managed in Portable Text format. We will add customizations related to the data being handled.

./schemaTypes/portableTextType.ts

Add an extension for external images.

./schemaTypes/externalImageType.ts

We will limit the schema extensions to these two points for now.

Add an icon

In the official content, we add an icon library immediately after creating a project. Actually, the schema definition includes an icon field where various icons can be specified. This time, we'll adopt the icon library provided by Sanity to maintain consistency for images and other elements in the admin interface.

The icon library additions are as follows:

sh

Reflect the schema

Simply placing the created schema file will not cause it to be reflected. Please update the file ./schemaTypes/index.ts as follows.

./schemaTypes/index.ts

Changes will take effect once the added schema is reflected in this file.

Spin up project

Once procedures such as schema extension are complete, execute the following command.

sh

After a moment, the Sanity admin interface will appear.

Image

We will proceed with migrating WordPress content to this environment.

Summary

For this migration from WordPress, we're proceeding with the sample data schema as-is. After the migration is complete, you can customize it to fit your desired environment.

The code up to this point is publicly available in the following repository for reference.

The steps on this page are published on the official website at the following location.