Complete Guide to Setting Up Sanity CMS
Sanity CMS is a powerful headless content management system, and ContentEngine integrates with it natively. This guide walks you through everything from creating your Sanity project to publishing your first AI-generated blog post.
What Is Sanity CMS
Sanity is a headless CMS that stores your content as structured data and delivers it through APIs. Unlike traditional CMS platforms like WordPress, Sanity separates your content from your presentation layer, giving you complete flexibility in how and where your content appears.
For ContentEngine users, Sanity is the ideal publishing destination. Its structured data approach means AI-generated content can be automatically mapped to the correct fields - title, body, slug, meta description, and custom fields - without manual formatting or copy-pasting.
Sanity offers a generous free tier for small projects, real-time collaborative editing through Sanity Studio, and a powerful query language called GROQ that makes retrieving your content straightforward for any frontend framework.
Creating a Sanity Project
Setting up a new Sanity project takes about five minutes. You will need Node.js installed on your machine. The Sanity CLI walks you through project creation, dataset configuration, and initial schema setup interactively.
During setup, you will choose a dataset name (typically "production") and a project name. Sanity creates a project ID automatically - this is what you will provide to ContentEngine to connect the integration. Save your project ID and dataset name for the connection step later.
Setup Tip
Create a separate dataset called "staging" for testing ContentEngine integration before connecting to your production dataset. This lets you experiment with generated content without affecting your live site.
Schema Design for Blog Content
Your Sanity schema defines the structure of your blog posts. ContentEngine reads this schema to understand which fields exist and maps generated content accordingly. A well-designed schema makes the integration seamless.
At minimum, your blog post schema should include a title field (string), slug field (slug type), body field (Portable Text / block content), excerpt or description (text), published date (datetime), and author reference. Optional but recommended fields include categories, tags, meta title, meta description, and featured image.
ContentEngine automatically detects common field patterns. If your schema uses standard naming conventions (title, slug, body, description), field mapping happens automatically. For custom field names, you can configure the mapping manually in ContentEngine settings.
Connecting ContentEngine
With your Sanity project and schema ready, connecting ContentEngine takes three steps. First, generate a Sanity API token with write permissions from your Sanity project settings at sanity.io/manage. This token allows ContentEngine to create and update documents in your dataset.
In ContentEngine, navigate to your workspace settings and enter your Sanity project ID, dataset name, and API token. ContentEngine encrypts the token with AES-256-GCM and never exposes it to the client-side browser. Once saved, ContentEngine reads your schema and presents the field mapping interface.
Review the automatic field mapping and adjust any custom fields. ContentEngine shows a preview of how generated content will map to your Sanity document structure. Once you confirm the mapping, the integration is live and ready for publishing.
Publishing Your First Post
With the integration connected, generate a blog post using ContentEngine's AI pipeline. Enter a topic, let the AI create a title and outline, then generate the full draft. Review the content for accuracy and brand voice alignment.
When you are happy with the draft, click the publish button. ContentEngine creates a draft document in your Sanity dataset with all fields mapped according to your configuration. The post appears in Sanity Studio as a draft, where you can make final edits and publish to your live site.
Publishing Tip
ContentEngine always creates drafts, never directly published documents. This gives you a safety net to review every post in Sanity Studio before it goes live. You can change this behavior in your workspace settings if you prefer auto-publishing.