🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Content modelling problems with blog websites and page builders

6 replies
Last updated: Mar 31, 2021
Hey fellow devs!I need your opinion about a content modelling problems I often run into with many clients:
Let's take a blog website. In the CMS I have an "Blog Article" document type and every article generates one page (
/blog/article-slug)Then I also have a "Page" type with a page builder which generate page at the top level (
/page-slug). (All my clients asks for some sorts of page builder).So far so good.

But then comes the index page that lists all the blog posts (
/blog). In my opinion, the "cleanest" way is just add the route "manually" in the pages directory (pages/blog/index.js). The problem is that this page doesn't appear in the CMS. So content editors cannot edit the title or other page metadata and also they cannot modifiy its position in the navigation. The solutions here is keep separate "routes" and "pages" in the CMS, like shown in the Sanity Next.js Starter Template . In the "Route" type they can manage the route metadata and the navigation no longer references pages but routes.
But then contents editor would like to write some introduction text before the blog index list... At that point, I just created a "Blog Index" object that is available in the page builder. So content editors can freely choose where the blog index is displayed. Recently I've started doing this by default for all new websites because it's too much trouble changing the schema afterwards. In regards to data modelling, it feels a bit silly to have a "show blog articles here" object inside the page builder, since the blog index in one place. But all in all I think that because I kept the "Blog Article" as a separate document type, it still valid structured data.
Actually now that I've written that message, I think that my final approach makes a lot sense for web agencies building websites for clients who need flexibility and don't want to hire the services of a developer for small changes. For companies with inhouse developers, we can have more content "hardcoded".
Feb 24, 2021, 8:34 AM
I think this is a sensible approach :D
Feb 24, 2021, 9:27 AM
I am currently building a site where I try to tackle this same problem.
What I ended up doing was to create a singleton page
(maybe could be named
or similar) that has a hero object etc to edit the title of the page and some descriptions and so on. This
also has a
slug which I set to the same value as where I define the route in pages folder (i.e.
). This way I can add the possibility for the content creator to link to the blog index page via internal links.
Feb 24, 2021, 2:59 PM
I also think it sounds sensible to have a “Show blog articles component” that editors can freely move around. 🙂
Feb 24, 2021, 3:29 PM
user J
That's also a good approach. Thanks for sharing.Yes, beside the metada and navigation issues, there's also the internal links issue.
Feb 27, 2021, 9:56 AM
I usually create a "Blog articles" module where I allow content editors to do whatever they need. I like to give them 2 options:
- Selected articles
- Show all (boolean)

With this approach, they can use the module wherever the modules builder is available at, and they can select the articles they want, list them all, or a mixed of both excluding from the list the ones that they already have manually selected.

This approach is pretty flexible and works really well.
Mar 31, 2021, 12:36 PM
user L
I have actually also used that on some sites, I had totally forgotten :). In addition to your options I have included a third one: Latest posts
Mar 31, 2021, 2: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?