Skip to content

Using Sanity Spaces for Multi-Site CMS Setup (5+ Websites)

9repliesLast updated: Nov 7, 2026

Has anybody used the experimental spaces feature to setup Sanity as a multi site CMS? I’m thinking about the best way to setup Sanity to handle 5+ different websites
AI Update

"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:

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:

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

You can also combine the two: use one dataset, and give each site its own workspace whose Structure filters to that site.

Show original thread
9 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.

Related contributions