Creating a group of singletons in Sanity Structure Builder
Looking at grouping singletons in Structure Builder, here's what works well:
The cleanest approach is to use a regular S.list() as a parent container, then nest your singleton document items inside. Here's a practical example:
export const structure = (S) =>
S.list()
.title('Content')
.items([
// Group of singletons
S.listItem()
.title('Settings')
.child(
S.list()
.title('Settings')
.items([
S.listItem()
.title('Site Settings')
.child(
S.document()
.schemaType('siteSettings')
.documentId('siteSettings')
),
S.listItem()
.title('Navigation')
.child(
S.document()
.schemaType('navigation')
.documentId('navigation')
),
S.listItem()
.title('Footer')
.child(
S.document()
.schemaType('footer')
.documentId('footer')
)
])
),
S.divider(),
// Regular document lists
...S.documentTypeListItems().filter(
item => !['siteSettings', 'navigation', 'footer'].includes(item.getId())
)
])A few helpful tips:
Use dividers for visual separation: The S.divider() method creates nice visual breaks between groups. You can even give them titles with .title('Settings').
Consistent IDs: Make sure your documentId() matches the actual document ID you want to edit. For true singletons, you'll want to configure your schema to prevent multiple instances from being created (filtering out templates, removing duplicate/delete actions, etc).
Filter out from main list: Notice the .filter() at the end - this prevents your singleton types from appearing twice (once in your grouped list, and again in the auto-generated document type lists).
Icons make it clearer: You can add icons to your list items with .icon(YourIcon) to make the groups more visually distinct.
If you want an even simpler setup for singletons without all the manual configuration, check out the singleton-tools plugin which handles a lot of the boilerplate automatically.
Show original thread3 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.