Hi,
I’m currently creating the content model for a website with Compose. Previously I’ve always hardcoded the routes for the different page urls of my websites and through having a few different page types been able to fetch these by a slug field. This time my tree is a bit larger and possibly several layers deep. The data and visuals of these pages for most of these paths are basically the same and having a different content type just to make another url structure for that page work sounds silly.
I’m using Next.js for my front-end and I am now exploring a way to dynamically build up the page tree by having an optional children field with page references on my page content type. The children can have children of their own, thus creating a fully CMS driven page tree through recursion. In Next.js I’m now fetching and building up a page tree dictionary in memory by getting all these pages from top to bottom. While my proof of concept works as expected, I’m concerned for scalability and performance issues if the website grows. The problem is also that the Contentful Content API returns the content field of the page, eventually resulting in too large response sizes or linked entries limits.
I’ve been reading as much as I can about this, but there isn’t a lot to go on. I know Contentful isn’t like a traditional page-centric CMS out of the box, but I am building a website and I don’t want to create different page content types every time I want to have a nested page in a hierarchy that doesn’t yet exist. Especially since the page can stay the exact same content model wise. With the current concept of the site this will already result in 10-15 page content types already and that will most likely grow in the future.
So for a tree like this:
/a/:slug
/b/:slug
/c/:slug
Do I really need to make new content types for the pages behind a,b and c even though they might be exactly the same model-wise?
Does anyone have any ideas or tips on how to basically tackle a dynamic sitemap / page tree from within Contentful or how to prevent creating new page content types whenever it needs a different URL / path on the website (nested)?