How to set title for singleton document without title field in Studio v3?
Perfect! I found the exact answer to your question. The solution is to use the preview configuration in your schema, not in the structure definition.
For singleton documents without a title field, you can add a custom preview to your schema that returns a static title. Here's how to do it:
export default {
name: 'siteSettings',
type: 'document',
title: 'Settings',
preview: {
prepare() {
return {
title: 'Settings'
}
}
},
fields: [
// your fields here
]
}The key insight is that the "Untitled" text in the document editor panel pulls from the preview configuration, not from the Structure Builder's .title() method. The Structure Builder's title only affects the navigation sidebar, not the document pane header.
Since your singleton doesn't have a title field to pull from, you can use the prepare() function in the preview configuration to return a hardcoded title. This changes what displays in:
- The document pane header (where you're seeing "Untitled")
- Document lists
- Reference fields
- Search results
The prepare() function doesn't need a select object if you're just returning static values. It won't write anything to your document—it only changes the display in the Studio interface, which is exactly what you want for a singleton.
This approach is particularly useful for singletons like Settings, Site Config, or other documents that don't naturally have a title field but need a meaningful display name in the Studio UI.
Show original thread8 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.