Page Anchor Tag Helper

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

Usage

The page anchor tag helper can be used with html anchor (a) tags. The following attributes can be used. Either re-page or re-page-id is required.

  • re-page - the page object to render the href for. Must be an object of type IPublishedPage.
  • re-page-id - the id of the page to render the href for. This is ignored if re-page already contains a valid page object.
  • re-route-* optional - any route values that will be passed to the url.
  • re-default optional - the action to take if the page does not exists or is not published. The following options are available:
    • DefaultAction.None default - do nothing; the anchor will be rendered without (overwriting) the href attribute.
    • DefaultAction.ClearContent - clears the anchor content but renders the tag.
    • DefaultAction.RemoveTag - completely removes the anchor from the output.

Examples

<body>
    <a re-page="await Model.NextSiblingAsync()">Next article</a>

    <a re-page-id="Model.ParentId">Go up...</a>

    @for (var i = 1; i++; i <= nrPages)
    {
        <a re-page-id="Model.ParentId" re-route-pagenumber="@i">Page @i</a>
    }
</body>

Remarks

In case of multi language websites, the url that is rendered is a link to a page with the same culture.