I am working on a Contentful Next.js app using Compose. I have been round and round on the best way to link pages and keep track of urls.
This is the structure of the page types:
- Company (Page Type of Landing) /company
– Values (Page Type of Company) /company/values
- Expertise (Page Type of Landing) /expertise
– Industry (Page Type of Industry) /expertise/industry/[slug]
I am trying to determine the best way to link a landing page to a detail page and detail page to landing. The detail pages have a link e.g. “Back to Company” or “Back to Expertise” so it need access to the parent page title, slug and contentType. contentType is currently being used to get the url path before the slug.
- Landing pages have content models that include a Link field that references the entry type “Compose: Page”.
- The detail pages have a Parent Link field that reference the entry type “Compose: Page”.
This is how it ties them into a child parent relationship. I’m not sure the best way to tie them together in Contentful.
When a landing page has a content model that links to a detail page and the detail page has a reference back to the parent page, the Next.js app errors: “Reason: Circular references cannot be expressed in JSON” which makes sense because it is circular. When I change the “include” param in “getEntries” from 10 to 4 it resolves, but links do not have the “sys.contentType” anymore. Changing the include value seems like the wrong way to go.
On the detail page , should it run another query to get the full parent page link so it has access to “contentType”? Or is there a better way to structure the page types, etc.?
Thank you for any advice and help.