We are using DXA 2.2.3 and have the following mappings:

[SemanticEntity(EntityName = "Link", Prefix = "l")]
public class Link : EntityModel
    public string Url { get; set; }


The Url property is resolved to:


But I would like to add an Id of a Component which it is linked to as an url fragment/hash, so for example I would like to have an url


In addition, this fragment should appear in the resolved link only in case the linked Component is based or not based on a certain Schema. So I need to check the Schema Id and then consider adding an anchor to a link.

What is a proper way to handle such a case? Any solution on web app side?


1 Answer 1


If you map a Component Link field to a property of type string, the semantic mapping will use the resolved link URL which is injected in the DXA R2 Data Model by the DXA Model Service/Extension.

Unfortunately, this part of link resolving is not customizable. However, if you map a Component Link field to an Entity Model, you will have access to the underlying Component ID (it will be mapped to the Entity Model's Id property).

If you give that Entity Model a string property which is annotated with [SemanticProperty("_self")], you will also have access to the resolved link URL.

You can then construct the combined URL yourself (for example, by adding a property to your Entity Model which combines the two).

  • BTW: You can also map the Component Link to a property of type Link. That also provides both the resolved URL and the Component ID. Jan 12, 2021 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.