Naalya Handbook
Sanity CMS

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"
IsA top-level record with its own _idA shape embedded inside a document
ExamplesPages, sections, post, author, siteSettingsbuttonConfig, statItem, faqItem
Used viatype: "reference" (and -> in GROQ)Its type name, as a field or in an array's of
Using each
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:

PartFields
SEO, in the seo grouptitle (has an initial value), seoTitle (required, max 60), seoDescription (required, max 160)
One group per sectionGives each section its own tab in the Studio
One required reference per sectionA 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. campusContactSection backs three fixed documents (-namugongo, -lugazi, -bweyogerere), ordered by displayOrder.
  • One document, several groups. The leadership page's leadershipSectionsDocument holds four groups, each an array of leaderMember objects. 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:

ObjectHolds
buttonConfigText, link, variant (radio list), and an icon shown only when showIcon is on
statItemValue, label, icon
activityCardA co-curricular activity with an image
campusCardA campus summary
facilityItemA facility
missionVisionCardA mission or vision card
iconSelectA 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:

MemberOptions
blockStyles normal, h1 to h4, blockquote; bullet lists; strong and em; a link annotation
imageHotspot, alt, caption, size (full, medium, small or custom pixels), aspect ratio
photoGridA set of photos shown as a grid with a lightbox
imageTextSectionAn 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.

On this page