In Sanity, content can be organized into variants based on specific conditions (e.g., locale: fr).
Variant Definition
A system document of type system.variant that describes the conditions for a variant.
- ID Path:
_.variants.<suffix> - Fields:
conditions (Record<string, string>), priority, and optional metadata.title. - Discovery: Use the
useAllVariants hook to fetch definitions studio-wide.
Variant Document
A version document containing alternative content for a base document.
- ID Shape:
versions.<scopeId>.<groupId> - groupId: The base published ID.
- scopeId: An opaque, server-generated hash. You cannot compute or guess this ID; you must discover it via lookup.
Document Metadata (_system field)
Every variant document contains authoritative metadata in the _system field:
| Field | Meaning |
|---|
variant | Reference to the system.variant definition (_.variants.*) |
group | Reference to the base published ID |
bundleId | The bundle: 'drafts', a release ID, or unset for a variant-of-published |
scopeId | The opaque hash from the document's own ID |
release | Reference to the release document (for release-scoped versions) |
delete | Soft-unpublish marker set by variant.unpublish |
Document Siblings
For one base document and one variant, up to three sibling documents can exist:
- Variant-of-published:
versions.<hashA>.<groupId> (bundleId is unset) - Variant-of-drafts:
versions.<hashB>.<groupId> (bundleId is 'drafts') - Variant-of-release:
versions.<hashC>.<groupId> (bundleId is <releaseId>)
Note: The base published and drafts. documents are separate and are never touched by variants.