Renders a href attribute on the target tag with the URL for the specified page.

Usage

The anchor tag helper can be used with html anchor (a) tags by adding a rx-href attribute to the element. The following attributes can be used.

  • rx-href required - the object to render a URL for. Must be a node view model (INodeViewModel), an object of type IPublishedContent, a Link object, or a valid node id string.
  • rx-href-culture optional - the culture of the page to link to. Uses the current request culture if not specified.
  • rx-href-if-empty optional - the action to take if the page does not exist or is not published. The following options are available:
    • EmptyAction.None default - do nothing; the anchor will be rendered without (overwriting) the href attribute.
    • EmptyAction.ClearContent - clears the anchor content but renders the tag.
    • EmptyAction.RemoveTag - completely removes the anchor from the output.

Examples

<body>
    <a rx-href="@await Model.NextSiblingAsync()" rx-href-if-empty="EmptyAction.RemoveTag">Next article</a>

    <a rx-href="@Model.ParentId">Go up...</a>

    @foreach (var link in await Model.Content.Articles)
    {
        <a rx-href="@link">@link.Title</a>
    }
</body>