How to remove documents from "Create New Document" menu in Sanity?
Perfect! This is exactly what you need. You can control which document types appear in the global "Create New Document" menu using the newDocumentOptions configuration in your Studio config.
Here's how to hide specific document types like homePage and siteSettings from that menu. In your sanity.config.ts (or .js) file, add this configuration:
import {defineConfig} from 'sanity'
export default defineConfig({
// ... your other config
document: {
newDocumentOptions: (prev, {creationContext}) => {
// Filter out singleton document types
const singletonTypes = ['homePage', 'siteSettings']
return prev.filter(
(template) => !singletonTypes.includes(template.templateId)
)
},
},
})This filters out your singleton documents from the global create menu while still allowing them to be accessed and edited through your Structure Builder configuration.
For a complete singleton pattern, you'll typically also want to set up your Structure Builder to show these documents with a fixed document ID. Here's a common pattern:
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
export default defineConfig({
// ...
plugins: [
structureTool({
structure: (S) =>
S.list()
.title('Content')
.items([
// Singleton documents with fixed IDs
S.listItem()
.title('Home Page')
.id('homePage')
.child(
S.document()
.schemaType('homePage')
.documentId('homePage')
),
S.listItem()
.title('Site Settings')
.id('siteSettings')
.child(
S.document()
.schemaType('siteSettings')
.documentId('siteSettings')
),
// Divider
S.divider(),
// All other document types
...S.documentTypeListItems().filter(
(item) => !['homePage', 'siteSettings'].includes(item.getId())
),
]),
}),
],
document: {
newDocumentOptions: (prev, {creationContext}) => {
const singletonTypes = ['homePage', 'siteSettings']
return prev.filter(
(template) => !singletonTypes.includes(template.templateId)
)
},
},
})The newDocumentOptions recipe shows more examples, including how to make this reactive based on the current user or creation context if you need more advanced filtering.
This approach gives you full control over what appears in that top bar menu while keeping your singleton documents accessible through the main navigation where you want them!
Show original thread7 replies
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.