Hide document types from "Create new document" button in Sanity Studio
Yes! You can absolutely hide specific document types from the "Create new document" button using the newDocumentOptions configuration in your Studio config.
In your sanity.config.ts (or .js) file, you can add a document.newDocumentOptions function that filters which document types appear in the global create menu. Here's how:
import { defineConfig } from 'sanity'
export default defineConfig({
// ... other config
document: {
newDocumentOptions: (prev, { currentUser, creationContext }) => {
// Filter out specific document types
return prev.filter(
(template) => !['documentTypeToHide', 'anotherTypeToHide'].includes(template.templateId)
)
},
},
})You can also make this context-aware. For example, if you want to hide certain types only in specific places (like in the Structure tool but not in other contexts):
document: {
newDocumentOptions: (prev, { currentUser, creationContext }) => {
const { type, schemaType } = creationContext;
// Hide 'pet' documents only when creating from Structure tool
if (type === 'structure' && schemaType === 'pet') {
return [];
}
return prev;
},
}The newDocumentOptions function receives:
prev: The default array of document creation optionscurrentUser: Information about the logged-in user (useful for role-based filtering)creationContext: Where the creation is happening (Structure tool, global menu, etc.)
This is particularly useful for:
- Hiding internal/system document types from content editors
- Role-based restrictions (showing different document types to different users)
- Context-specific creation (different options in different parts of your Studio)
You can find more details and examples in the newDocumentOptions recipe and the Studio customizations guide.
Show original thread25 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.