What would be the best practice for dealing with global data like a footer that should be on every page on the site and be the same for every page? The obvious answer would be to use a global called Footer i think and fill in the info there, however, would that mean i would need to make an extra request to the rest api along with the rest api request for the page itself?
@oloflarsson
It's that or you would have do a relation and attach the footer for every doc
If you are using something like nextJs or astro this could be part of your layout component
ah allright, so relation would be what makes most sense then i guess. thank you
Best practice for relation to global
We typically
domake that extra request for global data like header, mega menus, and footer. It’s simpler this way. Alternatively you’d need to open a custom endpoint which aggregates the api request with your globals, and the savings would not worth it imo. You probably wouldn’t want to use an after read hook because it runs far too often.
But wouldnt it be practically simpler like yhb said to create a relation to the footer collection/global and you wouldnt have to do any extra api calls? or would that have some other drawback im missing?
This would mean adding a relation to every single document, certainly possible but I don’t see a huge benefit in doing this
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.