Advice on best way to handle internal links

Hi there,

We’re relatively new to the DatoCMS way of doing things and are looking for advice on the best way to handle internal links around the website. Our ideal is that clients link to other records in the CMS to ensure consistency (e.g. if slugs change the links change) and a nice experience for the client.

We are currently building out a medium sized site that has around 13 different page types. From my current understanding if we want to be able to link to these pages we would need to specify all of those models in EVERY link or structured text field. Then expand all of those links in any GraphQL query that has a link or structured text and create a way to resolve those links on the front end to they end up pointing to the right place.

This seems like a) a lot of work given the nature of GraphQL and b) fairly unsustainable for a large website where there could be many structured text fields and link fields, all of which would need to be updated if we ever add a new page type in the future.

We have tried to limit the number of these fields by reusing blocks where possible and creating variables to use within GraphQL queries but it still fields very unwieldy. I could see it would be much simple to just make links a string but seems more error prone.

How do most people handle internal links? Is there a best practice way of doing things?

Thanks for your help,

Tim

Hello @tim1 and welcome to the community!

As you said, the best way to manage internal links to other records is through the “Link field” or the “Multiple links field”. Although you also can link records in-line through the structured text, if you plan on adding several links in the structured text, a block that contains a multiple links field could be a better solution.
But as you also said, every model must be specified in the link field, or structured text before linking it.

Ok - thanks for that. Just wanted to make sure we’re not missing something obvious. We have it all set up and working with the internal links so will see how it goes.

1 Like