The content model
How the Sanity Studio is shaped. Pages are singletons that reference section documents; small repeated shapes are shared objects; rich text is one type; one flat registry wires it all.
A page is a thin singleton that points at its sections. Each section is its own document. The small shapes inside sections are shared objects. To add a type, follow Creating a schema.
Splitting a page this way gives editors one tab per section, lets the frontend fetch one section by its id, and keeps sections reusable. The cost: "edit the homepage" means editing several linked documents.
The written rules live in the website repo: docs/sanity_rules.md, agents/sanity.agent.md and sanity/SINGLETON_PATTERN.md.
Documents vs objects
type: "document" | type: "object" | |
|---|---|---|
| Is | A top-level record with its own _id | A shape embedded inside a document |
| Examples | Pages, sections, post, author, siteSettings | buttonConfig, statItem, faqItem |
| Used via | type: "reference" (and -> in GROQ) | Its type name, as a field or in an array's of |
defineField({ name: "hero", type: "reference", to: [{ type: "heroSection" }] }),
defineField({ name: "primaryButton", type: "buttonConfig" }),
defineField({ name: "stats", type: "array", of: [defineArrayMember({ type: "statItem" })] }),Some sections still use inline objects
The rule is to reuse registered objects, but a few fields still declare anonymous inline objects, for example the Namugongo facilitiesSection.facilities and the landing gallerySection.images. Don't copy that in new code.
Pages are singletons
Every page document has the same three parts:
| Part | Fields |
|---|---|
SEO, in the seo group | title (has an initial value), seoTitle (required, max 60), seoDescription (required, max 160) |
| One group per section | Gives each section its own tab in the Studio |
| One required reference per section | A single reference, never an array |
Nothing in a schema marks it as a singleton. sanity/sanity.config.ts does it, in two places you must keep in step:
Pin the type to a fixed id in the structure: S.document().schemaType("landingPage").documentId("landingPage"). The id equals the type name, so GROQ fetches *[_type == "heroSection" && _id == "heroSection"][0] (see Single documents).
Add the type name to the exclusion filter on S.documentTypeListItems(), so it doesn't show in the generic list where editors could create a second copy.
The filter is a hand-kept list
The exclusion filter is a list of 75 type names with no automated check. Forget a new type and it appears twice in the Studio and can be duplicated, which breaks the fixed-id fetch the frontend relies on.
Two variations:
- Singleton family.
campusContactSectionbacks three fixed documents (-namugongo,-lugazi,-bweyogerere), ordered bydisplayOrder. - One document, several groups. The leadership page's
leadershipSectionsDocumentholds four groups, each an array ofleaderMemberobjects. Use this when sub-sections are alike and easier to edit together.
Shared objects
The objects in sanity/schemaTypes/shared/, re-exported from its barrel:
| Object | Holds |
|---|---|
buttonConfig | Text, link, variant (radio list), and an icon shown only when showIcon is on |
statItem | Value, label, icon |
activityCard | A co-curricular activity with an image |
campusCard | A campus summary |
facilityItem | A facility |
missionVisionCard | A mission or vision card |
iconSelect | A Tabler icon picker (custom input, in its own folder) |
Other objects live beside the documents that use them: faqItem in components/faqSection.ts, and leaderMember and sectionButton in leadershipPageSchema/. Every object, wherever it lives, must be in the registry.
shared/ holds objects. components/ holds standalone section documents (campusListSection, admissionSection, faqSection and others) that each have their own fixed id and are fetched apart from any page.
One rich-text type
All general rich text uses blockContent (sanity/schemaTypes/blockContent.ts), an array with four kinds of member:
| Member | Options |
|---|---|
block | Styles normal, h1 to h4, blockquote; bullet lists; strong and em; a link annotation |
image | Hotspot, alt, caption, size (full, medium, small or custom pixels), aspect ratio |
photoGrid | A set of photos shown as a grid with a lightbox |
imageTextSection | An image beside text, on the side the editor picks |
Define a narrower block array only when you want a limited editor; author.ts gives bio a plain block array instead of blockContent.
The registry
sanity/schemaTypes/index.ts exports one flat array, schemaTypes, and sanity.config.ts uses it as schema: { types: schemaTypes }. A type missing from that array doesn't exist for the Studio or typegen.
Export styles are mixed: post, author, category and blockContent use export default; everything else uses named exports. Match the file you're editing.