We are using Sitecore 10.1 and GlassMapper 5. We would like to create anchor links to renderings on the same page and to other pages.
Ideally we'd like to use the general link field type to generate these links. Is there an easy way to generate the anchors without having a control with a link field to create the anchors on each rendering.
Also is there an easy way to select such links from the anchor box in the insert internal link dialog?
This is an out-of-the-box feature of Sitecore's Horizon editor. As you are already on Sitecore version 10.1 you can use Horizon editor to link to an anchor on the current or another page:
#<anchor-name>; for the anchor link on ANOTHER page: expand the Optional parameters section and enter<anchor-name>(without#!) in the Anchor field;You can create anchors programmatically at a rendering level or give your content editors more flexibility and allow them to create anchors themselves in rich text field - in the HTML code an anchor can be inserted using the format
id=“anchor-name”.Find more details here.