Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Discussion on creating a standalone document for a homepage in headless CMS

8 replies
Last updated: Dec 13, 2021
Hi everyone, is it possible to create a standalone document that can only be created once ? For exemple a landing page, a header, a footer, etc...
Dec 13, 2021, 2:53 PM
I’m not sure if what you want to achieve is the proper approach with headless cms. You can build your homepage by pulling in different parts of all your content. But still if you want to represent homepage with a document I would most probably just hardcode in my website application that any document of type: xyz, with slug /home (or anything similar) will be my root page
Dec 13, 2021, 2:57 PM
Don't think so, don't know. But you could make a document type that has a reference to each of the types you only want 1 of.So you allow creating many frontpageS, headers etc (but you dont have to, of course) and then in the "mySiteElements"-documentType you select THE frontpage, THE header and THE footer you want to use.
Dec 13, 2021, 3:05 PM
user H
So if I understand, instead of having only one query for the home page, I would have multiple queries based on the different documents (blocks in my home page that can be used on other pages) ?
Dec 13, 2021, 3:06 PM
Actually it depends on what you want to display on the homepage. Remember you are in headless CMS, so you focus on structuring your data properly. And the data can be presented differently depending on the channel. You can have documents about different offers, a document or a few with some testimonials and you want to present all of this on the homepage.
Then you just build your homepage with e.g. next.js (or whatever you are using to build it) to get the data from multiple documents.

But as I said if you structure your content/docyments 1-to-1 with pages (which in my humble opinion is not the best option - maybe could work for simple sites like blogs) then you could hardcode slug /home to be served on the root URL
Dec 13, 2021, 3:35 PM
bottom line, yes, it’s not wrong to use multiple queries or (one query for multiple documents) to get what you need in order to properly display your page
Dec 13, 2021, 3:37 PM
Thank you, I understand now ! But imagine I have like a CTA, a description or some other little content I have to display on my homepage, I would have to create a document just for the home page anyway right ? And this document will also refer to more blocks like testimonials, pricing, etc
Dec 13, 2021, 3:39 PM
So cool, thank you very much !
Dec 13, 2021, 4:55 PM
You're welcome!
Dec 13, 2021, 6:08 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?