How to remove a document type from the "New document" dialog in Sanity Studio

17 replies
Last updated: Dec 19, 2022
Hi ! I can’t find a way to remove a documentId from the “New document” dialog in the studio. I want to block my teammates from creating a new “Site settings” document .. Could you help me ? 🙂
AI Update

Perfect! You can hide the "Site settings" document type from the "New document" dialog using the newDocumentOptions configuration in your Sanity config. This is exactly what you need for singleton documents that should only exist once.

In your sanity.config.ts (or .js) file, add the newDocumentOptions configuration:

import {defineConfig} from 'sanity'

export default defineConfig({
  // ... your other config
  document: {
    newDocumentOptions: (prev, {creationContext}) => {
      // Filter out 'siteSettings' from the new document menu
      return prev.filter((templateItem) => templateItem.templateId !== 'siteSettings')
    },
  },
})

If your document type has a different ID than the template ID, you can also check the schemaType:

document: {
  newDocumentOptions: (prev, {creationContext}) => {
    const {schemaType} = creationContext
    
    // Hide from the global "New document" menu
    if (schemaType === 'siteSettings') {
      return []
    }
    
    return prev
  },
}

This approach is particularly useful for singleton documents (like site settings, global config, etc.) where you only want one instance to exist. The document can still be accessed and edited through the Studio structure - it just won't appear in the "New document" creation dialog, preventing your teammates from accidentally creating duplicates.

You can also combine this with the Structure Builder to provide direct access to your existing site settings document, making it easy to find and edit without cluttering the new document menu.

Show original thread
17 replies
deskTool({ name: 'content',
title: 'Content',
structure: (S) =>
S.list()
.title('Content')
.items([
S.documentTypeListItem('tools'),
S.documentTypeListItem('collections'),
S.divider(),
S.listItem()
.icon(MdInfo)
.title('About')
.child(S.editor().schemaType('about').documentId('about')),
S.divider(),
S.documentTypeListItem('categories'),
S.documentTypeListItem('tags'),
]),
}),
This can be done in your deskTool! The «About» list item is the way ive done it
Are you sure it’s going to remove the document type from the “New document” dialog in the top left corner of the studio ?
Can you take a screenshot?
Sure I want to remove it from here
Can’t recall to see a icon there on a single page!
But give it a try
S.listItem() .icon(MdInfo)
.title('About')
.child(S.editor().schemaType('about').documentId('about')),
This is what you need
Let me try
I did it it’s not changing anything .. 😕
:/ Well currently not on a computer, but there is probably some people that can help! Monday tomorrow so Sanity people is back :saluting_face:
In the sanity.config.json

document: {
    newDocumentOptions: (prev, { creationContext }) => {
      if (creationContext.type === 'global') {
        return prev.filter((templateItem) => templateItem.templateId != 'settings')
      }
      return prev
    },
    actions: (prev, { schemaType }) => {
      if (schemaType === 'settings') {
        return prev.filter(({ action }) => !['unpublish', 'delete','duplicate'].includes(action))
      }
      return prev
    },
  }
Thanks for your help, I’ll try it !
Works perfectly. It was quite hidden in the docs to be honest
Yeah I know, found it by chance as well haha

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?