How to structure front page intro title and heading in Sanity schema?

8 replies
Last updated: Jun 19, 2020
Hello!
I'm implementing this very standard web site, with a front page, some products and a few topic pages.

How should I structure the content on the front page? In particular, there's this intro title and heading that I can't think of a place to put. I have a content type for products, and one for topics. I have a site settings content type, and a generic texts content type. Should I add another one? What should it be?
AI Update

For a standard website like yours, you have a few solid approaches for structuring front page content, especially that intro title and heading:

Option 1: Extend your Site Settings document (Recommended)

Since you already have a site settings content type, this is often the best place for front page-specific content. You can add fields like frontPageTitle, frontPageHeading, and frontPageIntro directly to your site settings singleton. This keeps all site-wide, one-off content in a single, easy-to-find location.

{
  name: 'siteSettings',
  type: 'document',
  fields: [
    // ... your existing settings
    {
      name: 'frontPageTitle',
      type: 'string',
      title: 'Front Page Title'
    },
    {
      name: 'frontPageHeading',
      type: 'string',
      title: 'Front Page Heading'
    },
    // Maybe add featured products/topics here too
    {
      name: 'featuredProducts',
      type: 'array',
      of: [{type: 'reference', to: [{type: 'product'}]}]
    }
  ]
}

Option 2: Create a dedicated Front Page/Homepage document

If your front page needs more complex structure (multiple sections, hero areas, content blocks), create a separate singleton document type called frontPage or homePage. This gives you more flexibility to build out a richer page structure using content blocks or modular sections.

{
  name: 'frontPage',
  type: 'document',
  fields: [
    {name: 'title', type: 'string'},
    {name: 'heading', type: 'string'},
    {name: 'intro', type: 'text'},
    {
      name: 'featuredProducts',
      type: 'array',
      of: [{type: 'reference', to: [{type: 'product'}]}]
    },
    {
      name: 'featuredTopics',
      type: 'array',
      of: [{type: 'reference', to: [{type: 'topic'}]}]
    }
  ]
}

What NOT to do:

Don't use your "generic texts" content type for this. That creates confusion about which text belongs where and makes it harder for content editors to find and update the front page content.

General principle:

Following content modeling best practices, think about whether this content is truly unique to one place (front page) or if it's reusable across contexts. Unique, one-off content like front page intros belongs in either site settings or a dedicated page document, not in generic content types.

For a standard site like yours, I'd lean toward extending site settings unless you anticipate the front page growing significantly more complex over time.

Show original thread
8 replies
Hi User, this would be a good question to post in content-modelling as well if you like. I’d say there are a few ways you can go here. You could create a singleton document for the front page and make it a kind of unique schema in your content model, which would give you plenty of freedom to specifically take care of the front page.
Alternatively, and more in line with the structured content philosophy, you could also create a generic
page
type document and let editors add various ‘modules’ to a
content
array field, for example. These modules can be reusable objects for the different pieces of content you’d like people to add to the pages.
If you already have a content type for texts, you could also choose to set up an array of references to those instead, but something like that could also live with other options in the content array above.

Hope this gives some ideas - for deep input, check the other channel
🙂
Maybe this can give you some inspirationStudio for this site
https://23september.se/
https://gist.github.com/User/7ba2a26b3e294da2781e692ba1692a51 <- my deskStructure.js
I would start with title, remember that you may need both page title and tab title, if you handle slugs through sanity you also need that for all the pages
Hi User, this would be a good question to post in content-modelling as well if you like. I’d say there are a few ways you can go here. You could create a singleton document for the front page and make it a kind of unique schema in your content model, which would give you plenty of freedom to specifically take care of the front page.
Alternatively, and more in line with the structured content philosophy, you could also create a generic
page
type document and let editors add various ‘modules’ to a
content
array field, for example. These modules can be reusable objects for the different pieces of content you’d like people to add to the pages.
If you already have a content type for texts, you could also choose to set up an array of references to those instead, but something like that could also live with other options in the content array above.

Hope this gives some ideas - for deep input, check the other channel
🙂
(Thanks User! Love the icons for Header/Footer btw 😄🧦)
you could also create a generic 
page
 type document and let editors add various ‘modules’ to a 
content
 array field
This is exactly what I ended up doing. And I think - at some point, it made Sanity as a CMS for these kinds of sites really click for me.
I'm back in love with Sanity now, thanks!
great page User ❤️
and thanks for the tip about content-modelling - I'll head over there right away

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.

Was this answer helpful?