Sanity Pioneers: Get early access to betas, extra AI credits, and a direct line to the engineering team. Apply now

How to define a singleton page in Studio v3?

4 repliesLast updated: Nov 29, 2025

How to define a singleton page in Studio v3. Can anybody point me to an example?
AI Update

A singleton page in Studio v3 is a document type that can only have one instance, perfect for things like your home page, site settings, or an about page. You'll need to configure three things in your sanity.config.js file to make it work properly.

Here's a complete example:

import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'

// Define which types should be singletons
const singletonTypes = new Set(['settings', 'homePage'])

// Define which actions should be available for singletons
const singletonActions = new Set(['publish', 'discardChanges', 'restore'])

export default defineConfig({
  // ... other config
  plugins: [
    structureTool({
      structure: (S) =>
        S.list()
          .title('Content')
          .items([
            // Create a direct link to the singleton document
            S.listItem()
              .title('Settings')
              .id('settings')
              .child(
                S.document()
                  .schemaType('settings')
                  .documentId('settings')
              ),
            
            S.listItem()
              .title('Home Page')
              .id('homePage')
              .child(
                S.document()
                  .schemaType('homePage')
                  .documentId('homePage')
              ),
            
            // Add other document types normally
            ...S.documentTypeListItems().filter(
              (listItem) => !singletonTypes.has(listItem.getId())
            )
          ])
    })
  ],
  
  schema: {
    types: [
      // Your schema types here
    ],
    // Hide singletons from the "New document" menu
    templates: (templates) =>
      templates.filter(({schemaType}) => !singletonTypes.has(schemaType))
  },
  
  document: {
    // Remove unwanted actions for singletons (like delete/duplicate)
    actions: (input, context) =>
      singletonTypes.has(context.schemaType)
        ? input.filter(({action}) => action && singletonActions.has(action))
        : input
  }
})

Important: You need to create the document instance first before adding its type to the singletonTypes set. Otherwise, you won't have a way to create it through the UI.

The three key pieces are:

If you want an easier approach, check out the singleton-tools plugin which handles all this configuration automatically.

The full guide with more details is available in the Sanity singleton document guide.

Show original thread
4 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