General help for DatoCMS

Hello there,

I have 2 simple questions:

  1. It has been the bane of my development with DatoCMS. How does one create breadcrumbs dynamically? Assuming that there are no hard coded pages, everything is in one content type called Pages, how does one query or generate the breadcrumbs? Take note also that it can be 2-3 levels deep.

  2. Preview Links: I have been following this plugin and Im getting an error: Failed to load resource: the server responded with a status of 401 (Unauthorized). Am I missing somethign?

Hi @nirodriguez,

For #1, it depends on your frontend routing setup. If all the pages are in one flat folder, can’t you just their slug for the URL? If they are nested inside each other, perhaps a plugin like https://www.datocms.com/marketplace/plugins/i/datocms-plugin-tree-like-slugs?s=slug could help? If I’m misunderstanding, could you please provide an example content hierarchy and how you want the breadcrumbs to look?

For #2: It’s a bit complicated to setup (sorry), but did you do all the steps in the readme (e.g. set up the webhooks on the Next endpoint, with proper env vars there etc.?) It looks like something is missing an auth header (your API key), probably, but hard to say without more detailed logging? Can you please more details and/or screenshots or a recording, but with the auth keys blurred out?

1 Like

Hi @roger ,

Thank you for your reply. Please see my responses below:

  1. That is exactly what I am looking for. Thank you for the recommendation for the plugin. Devs can then query it from the slug/url and create the necessary breadcrumbs.

EDIT: I just realised that the child pages must be defined in the nav tree. What if the child page is not defined in the nav tree?

  1. EDIT: I figured it out. The Preview Webhook URL didnt have the token query parameter. I think that was missing from the documentation (or I might have missed it)

Can you point me at a specific example, please? Like how does it look in the CMS, and what would you want the final slug to be?

You’re right, sorry! It’s commented in code, but it can probably be clearer in the readme too. I’ll update that.

all good sir! i’ve managed make the breadcrumbs based from the parent id and utilising graphql

1 Like