How to organize data for pages with different designs?

default discord avatar
hdodov
last year
1 1

If I'm making a blog, it's obvious that I need a Post collection, where each document represents a single article.

But what if I'm making a general-purpose marketing site where I have a few different pages that all have different designs and therefore need different fields for content? These solutions pop in my mind:

  1. Have a separate collection for each page.
  2. Have a single Pages collection. In this case, I don't see how each page would have different fields.
  3. Use the Global and specify each page as an object inside. That just sounds wrong.

The first approach seems the most rational, but what bothers me is that I'd have a collection with just a single document inside. Kind of like the Global collection. Does that make sense? Or there's a better way?

  • discord user avatar
    DanRibbens
    Payload Team
    last year

    Great question! I would head on over to the demo.payloadcms.com example and see if that accomplishes what you want. On the pages collection there is a design templating approach that is very flexible by giving content authors a choice of different layouts and using content blocks to make pages that are very composable.

    All the source code for the project is available too so take what you like and delete or modify the rest. It is found at https://gitbub.com/payloadcms/public-demo

    Does that help?

    2 replies
  • discord user avatar
    DanRibbens
    Payload Team
    last year

    You could also consider making a field in the pages collection called design as a select or radio type. Then use the conditional properties so that your design specific fields are only used when needed.
    That would be a good approach if you don't want to give as much editor control as the public-demo has.

  • default discord avatar
    hdodov
    last year

    Sounds great, thanks!

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.