Using one Sanity Studio for domain and subdomain with different documents

3 replies
Last updated: Apr 18, 2024
Can I use one sanity studio and use specific documents for my primary domain and different specific documents for a subdomain? (or would I need the enterprise feature, where I can change between different datasets?)
AI Update

You can absolutely use one Sanity Studio with specific documents for your primary domain and different documents for a subdomain without needing an enterprise plan. You have a couple of approaches:

Option 1: Single Dataset with Filtering (Simplest)

Keep all your content in one dataset and filter documents based on which site they belong to. Add a field to your documents (like site: 'main' | 'subdomain') and then:

  • In your Studio, use conditional desk structures to show only relevant documents
  • In your frontend, query only the documents for that specific domain using GROQ filters

This works on any Sanity plan and is the most straightforward approach for most use cases.

Option 2: Multiple Datasets with Workspaces (Also Free)

You can create multiple datasets within the same project and use workspaces to manage them in one Studio. Each workspace connects to a different dataset:

// sanity.config.ts
export default defineConfig([
  {
    name: 'main-site',
    title: 'Main Site',
    projectId: 'your-project',
    dataset: 'production',
    // ... schema and plugins
  },
  {
    name: 'subdomain',
    title: 'Subdomain',
    projectId: 'your-project', 
    dataset: 'subdomain',
    // ... different schema if needed
  }
])

This gives you a workspace switcher in your Studio to toggle between datasets. This feature is available on all plans, including the free tier - you're not limited in the number of datasets per project.

Your primary domain would query from the production dataset, while your subdomain queries from the subdomain dataset. Each dataset can have its own schema, though you define all schemas in your Studio config.

When You'd Need Enterprise Features

The enterprise-only feature is cross-dataset references - if documents in one dataset need to directly reference documents in another dataset. For most multi-site setups where content is independent between domains, you won't need this.

The workspaces approach is particularly powerful for multi-site scenarios and is commonly used for exactly your use case - managing multiple domains or brands from a single Studio while keeping content separated.

Show original thread
3 replies
If I understand correctly, if they are different documents in both instances you can use Workspaces: https://www.sanity.io/docs/workspaces which kind of acts like two elements in the config, which creates a kind of dropdown in the studio to pivot between them.
Enterprise would come into play if the
two datasets needed to make references between each other .
Awesome! Thank you so much
No problem!

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.

Was this answer helpful?