Best practices for using page structure builder in Sanity and decoupling from traditional CMS thinking.
28 replies
Last updated: Dec 19, 2023
N
The page structure builder works nice. But can I like remove the page builder structure from a homepage only for instance? So the homepage should hide this option. Because on the homepage I have Latest Articles, Latest Projects but I don't need this on other pages but only homepage. But on the other hand I do need the page structure builder on all other pages if that makes sense? What is best practice and advice to do here?
Jan 2, 2023, 10:29 PM
S
Hello
user Q
Which page structure builder are you alluding to?Jan 2, 2023, 10:31 PM
S
I am completely lost 😆
Jan 2, 2023, 10:32 PM
N
Structured content for page building from the last example you have shared with me 😊 I am only confusing about the mindset on headless CMS now. Coming from a WordPress environment where you where able to hide specifics fields based on the page type etc.
Now I have a design for a client on the homepage it's showing latest projects and news.
Because for a blog for instance you won't use a page structure builder but just output everything because the layout is the same.
But a page like contact or about or homepage can look different.
Now do I use the page structure on type "page" all the time for creating pages as a best practice?
Or can I tell Sanity that only exclude the page builder (array) from a specific page ID/Slug?
Now I have a design for a client on the homepage it's showing latest projects and news.
Because for a blog for instance you won't use a page structure builder but just output everything because the layout is the same.
But a page like contact or about or homepage can look different.
Now do I use the page structure on type "page" all the time for creating pages as a best practice?
Or can I tell Sanity that only exclude the page builder (array) from a specific page ID/Slug?
Jan 2, 2023, 10:40 PM
N
And what is best practice and the advice to do? Because all those starters are usually blogs. Which makes sense... it's easy to start with.
Jan 2, 2023, 10:41 PM
S
well yes and no, it depends on your needs 🙂You can use whatever you need from your sanity data. basically setup your structured content on the main page parts and then use the page builder for landingpages or additional informational pages for example.
you can and should decouple the 1:1 thinking of other cms’ -> use the page builder for quick contained landing pages, setup overall informational
Then in your front end you dynamically load different parts of your document types or page parts into your pages.
You get
for
but also and as well as a selection of news items and also projects that should be featured`"projects": *[_type == 'project' && featured == 'true']|order(finishDate, desc){title, team, image, client, description)[0...3]` under the 4 featured projects you will implement a button
Clicking on a project there will direct you to
I hope this is clear
😅
you can and should decouple the 1:1 thinking of other cms’ -> use the page builder for quick contained landing pages, setup overall informational
settingsingleton doc, with fields for about us etc. as well as impressum text, social links, contact info and more.and then you have a doc type called person which is basically the team with name, email, short bio etc, then you have testimonial docs, news & project docs, with title, slug, body and publish date and all the other fields;
Then in your front end you dynamically load different parts of your document types or page parts into your pages.
You get
setting.impressum(block content) and
contactinfo for the page route
/impressum
for
/aboutyou get
"team": *[_type == 'person']{name, team, profileImage)
"aboutText": *[_type == 'setting'].aboutText
"testimonials": *[_type == 'testimonial' && useForAbout == 'true']{sourceName, body, image)
"news": *[_type == 'news' && featured == 'true']{title, team, excerpt)[0...3]|order(_publishAt, desc)
All Projectswill will lead to
/projectswhere you will need
"projects": *[_type == 'project']|order(finishDate, desc){title, team, image, client, description, slug)
/project/SLUGwhere you get the data from one specific project with a
bodyand so much more info.And then for landingpages, which you generate with
[slug].tsxin nextJS you query for the
contentarray and render it there.
I hope this is clear
😅
Jan 2, 2023, 11:02 PM
S
And the beauty is, that you can then use the same logic in the page builder:lets say you have a section
testimonialBannerSectionwhich can have 3 testimonials in a slider or whatever. Now you set it up as an object with an array of
max 3items which are
referencesto your
testimonials💥In your front-end you need to setup a special query for those things then.
Jan 2, 2023, 11:10 PM
N
So inside a singleton I ahould place something like about and add a reference to the team schema.
And on next you would have something like: app - projects/blog/about - page.tsx and use the queries which are needed on each page and based on how you structured it?
And on next you would have something like: app - projects/blog/about - page.tsx and use the queries which are needed on each page and based on how you structured it?
Jan 2, 2023, 11:14 PM
N
And settings global query like desc, info, socials share it it to all the nested routes like nav and footer info. But the content on a page should fetch and load the query which is needed for that specific page.
But in the app root folder the page.tsx file just output the data which is needed on that page?
So its easier actually not to have page structure data unless tou have one global page
But in the app root folder the page.tsx file just output the data which is needed on that page?
So its easier actually not to have page structure data unless tou have one global page
Jan 2, 2023, 11:16 PM
S
Exactly! You only make content “static” in sanity, if you might not reuse it. A landingpage content wont be reused, but certain parts might. If they will be reused, it is a signal for you to either make it part of an overall singleton doc or if you need variation, a doc type by itself
We can also have a short zoom and go through your content structure/plan (record and then share it?)
We can also have a short zoom and go through your content structure/plan (record and then share it?)
Jan 2, 2023, 11:16 PM
S
So its easier actually not to have page structure data unless tou have one global pageYes, but sometimes no… It really depends on what the needs are and also thinking on how this will scale
Jan 2, 2023, 11:17 PM
S
Or you can read watch carrie hanes stuff… she is amazing and all I am brain-vomiting here is based on her work (or what I learnt from it)
Jan 2, 2023, 11:19 PM
N
Right! So actually the steuctured builder is nit really important since all designs for websites are ynique. The thing a clients sees is what they will get. I am overthinking! It’s better to have a global query for settings and unique queries for pages like about. Team, contact etc. This way I can have a contact form on a /contact/page.tsx and have still have a unique layout. And since I am using static generated pages there is no need really to have a page builder unless its a landingpage.
Jan 2, 2023, 11:19 PM
S
Yeah I mean to explain the approach “Dont think of design! We need to think about your content first and then understand your long term needs, design will always be changeable” is pretty hard sometimes…But I think it is worth rethinking stuff over and over again before sitting down and coding …
I usually use some sort of flow chart (figjam or miro) to mix and match
I usually use some sort of flow chart (figjam or miro) to mix and match
Jan 2, 2023, 11:21 PM
N
That’s my problem overthinking and wanting to have it “perfect” from the start. Need to get out of that mindset from classic CMS like WordPress
Jan 2, 2023, 11:22 PM
N
Well will have the design soon so sounds good about zoom 😃 to see how you would do things theoretically once I get that “click” in my brain it’s gonna be easy
Jan 2, 2023, 11:23 PM
S
I can show you some of my flow charts … wait…
This is something I do sometimes, its just notes to explain things …
This is something I do sometimes, its just notes to explain things …
Jan 2, 2023, 11:24 PM
S
You can also use the plugin from
user B
Tapi in FigJam, where you can do WONDERS for content planning!Jan 2, 2023, 11:26 PM
S
Jan 2, 2023, 11:28 PM
N
Perfect notion link!
https://www.figma.com/community/widget/1066408362543146472
This one right? Going to check it out! I want to get out of that complex thinking mindset.
https://www.figma.com/community/widget/1066408362543146472
This one right? Going to check it out! I want to get out of that complex thinking mindset.
Jan 2, 2023, 11:28 PM
S
This is so cool, and you can then export your ideas as A READY SCHEMA SET 😱 🧠 :mindblown:
Jan 2, 2023, 11:29 PM
N
No way! From a design to ready schema sets??
Jan 2, 2023, 11:30 PM
S
I kid you not,
user B
is just 🔥 And he was one of the people who just zoomed with me when I was stuck and beginning with Sanity, so … I carry on his traditinJan 2, 2023, 11:32 PM
N
Wow! Its too late now to look at it. But I will check this out first perfect tips and links 🌟 so nice!
Jan 2, 2023, 11:33 PM
S
haha true… we are in the same timezone!Uff I wanted to do some after work guide writing but … well got lost in the community
😅
😅
Jan 2, 2023, 11:36 PM
S
Buena notte!
Jan 2, 2023, 11:36 PM
N
You too! ✨
Jan 2, 2023, 11:37 PM
J
^ this thread should be pinned or turned into an article. It's all 🔥
Nov 11, 2023, 4:42 PM
S
Actually been working on a guide, but its so busy at the moment, and this needs a lot of extra setup work, but I am on it 😉
Dec 19, 2023, 9:59 AM
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.