Using Sanity Spaces for Multi-Site CMS Setup (5+ Websites)
"Spaces" was an experimental feature of the old Studio. In Studio v3 and later you have two current ways to run 5+ sites from one Studio:
- A workspace for each site, each with its own dataset. You get full separation.
- One dataset with a
sitefield on documents. It's cheaper, and sharing content and media between sites is easy.
Decide based on how many datasets your plan includes. On the pricing page, Free and Growth both include 2 datasets. Growth can add more at $999 per dataset per month, and Enterprise has a custom number of datasets. With 5+ sites, one dataset per site usually means Enterprise.
Option 1: one workspace per site
Pass an array to defineConfig. Each entry is a full workspace with its own dataset, basePath, plugins and schema, and editors switch between them from a dropdown next to the Studio title (Workspaces):
// sanity.config.ts
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {siteASchemaTypes, siteBSchemaTypes} from './schemaTypes'
export default defineConfig([
{
name: 'site-a',
title: 'Site A',
basePath: '/site-a',
projectId: 'your-project-id',
dataset: 'site_a_production',
plugins: [structureTool()],
schema: {types: siteASchemaTypes},
},
{
name: 'site-b',
title: 'Site B',
basePath: '/site-b',
projectId: 'your-project-id',
dataset: 'site_b_production',
plugins: [structureTool()],
schema: {types: siteBSchemaTypes},
},
])Notes:
- Each workspace registers only its own schema types. You don't need to put every type in every workspace.
schema.typescan also be a function(prev, context), andcontext.datasettells you which workspace's dataset is active (multi-tenancy guide). - The
hiddenoption on a workspace only hides it in the UI. It does not restrict data access, so use role-based permissions for that. Custom roles and resources need Enterprise. - To share content between datasets (for example a global dataset), use cross-dataset references. These are Enterprise only (cross-dataset references).
deskToolfromsanity/deskis now a deprecated alias. UsestructureToolfromsanity/structure, or runnpx @sanity/cli@latest codemod deskRename(Desk is now Structure).
Option 2: one dataset with a site field
Create a site document type. Give every site-specific document a reference to its site. Then use Structure and initial value templates so editors rarely touch that reference themselves. All sites share one media library, and you can share document types across sites. The trade-off: watch for naming collisions, and every frontend query must filter by site (multi-tenancy guide).
// structure.ts
import type {StructureResolver} from 'sanity/structure'
export const structure: StructureResolver = (S) =>
S.list()
.title('Sites')
.items([
S.listItem()
.title('Pages by site')
.child(
S.documentTypeList('site').child((siteId) =>
S.documentList()
.apiVersion('2024-06-01')
.title('Pages')
.filter('_type == "page" && site._ref == $siteId')
.params({siteId})
.initialValueTemplates([
S.initialValueTemplateItem('page-by-site', {siteId}),
]),
),
),
S.divider(),
...S.documentTypeListItems(),
])// in defineConfig
plugins: [structureTool({structure})],
schema: {
types: schemaTypes,
templates: (prev) => [
...prev,
{
id: 'page-by-site',
title: 'Page for site',
schemaType: 'page',
parameters: [{name: 'siteId', type: 'string'}],
value: ({siteId}) => ({site: {_type: 'reference', _ref: siteId}}),
},
],
},A documentList with a filter must set .apiVersion(). Parameterized templates only work as expected inside Structure (Structure Builder cheat sheet, initial value templates).
Choosing
- Separate datasets or workspaces suit sites with very different schemas, separate teams, or strict isolation, if your plan includes enough datasets.
- A single dataset suits sites with similar models, a shared media library, or shared content, especially on Free or Growth.
You can also combine the two: use one dataset, and give each site its own workspace whose Structure filters to that site.
Show original thread9 replies
Was this answer helpful?
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.