Anchor for Links

Would be nice to have the ability to add an anchor to links without the need for an additional field. So we can link to another page and scroll to the anchor-id.

Just for clarity, do you mean you are linking to another internal Dato record (by reference, inside a “Link” field), instead of a URL?

But you would like to be able to jump to a specific part of that linked record (like a certain heading in a Structured Text or HTML field, for example)?

Excactly. Linking to a Dato record and not an external link/url.

I set the anchorId on my blocks and would like to jump there.

Also setting anchors for headings in structured text would be a nice addition.

Makes perfect sense. I’d love to see that too.

Thanks for the request, and please remember to vote on it in the upper left!

Any plans or updates from Dato to implement this? it would be very helpful to add anchor text in in-text links for SEO:

Hey @y.zarins, welcome to the forum :slight_smile:

Sorry, we still don’t have a great solution for this yet. It’s something I’ve pitched internally too, but so far there is not yet any planned work on it. I’ll update this thread if that changes.

In the meantime, there are a few workarounds you can consider.

  1. If you are linking to an external URL (as opposed to another Dato record), you can just append the anchor hash to the URL itself:

  2. If you are linking to another Dato record, you can enable the “Show advanced Meta editor for links” option in that field’s Presentation settings:

    That lets you add additional metadata to that link:

    But please note that you’ll have to implement a corresponding custom renderer on the frontend to render that anchor meta into a real <a href="#myHeading"> tag.

Let me know if you need a complete example (and what stack & language you’d want it for). Sorry for the hassle!

These are really helpful tips, thank you so much!