URL Helpers

URL generation and manipulation functions that handle path resolution and fragment extraction.

HelperPurposeParametersReturns
rootUrlReturns the root URL of the siteuri
rootRelativeUrlConverts site-relative URL to document-relativeuriuri
fragmentExtracts fragment (anchor) from a URL for linking to sectionsuristring?

rootUrl

Provides the root URL of the site.

Syntax:

{{#rootUrl}}

Returns: A URI object that is either absolute or relative to the current page, depending on the context

Examples:

{{#rootUrl}}    {{!-- Absolute: "https://example.com/" --}}
{{#rootUrl}}    {{!-- Relative: "../../" --}}

rootRelativeUrl

Converts a site-relative URL to a document-relative URL based on the current page context.

Syntax:

{{#rootRelativeUrl uri}}

Parameters:

Returns: A URL string that is either absolute or relative to the current page, depending on the context

Examples:

{{#rootRelativeUrl "styles/main.css"}}     {{!-- "https://example.com/styles/main.css" --}}
{{#rootRelativeUrl "index.html"}}          {{!-- "https://example.com/index.html" --}}

fragment

Extract the fragment identifier of a URL for linking to specific sections.

Syntax:

{{#fragment url}}

Parameters:

Returns: URL fragment string (without # prefix)

Examples:

{{#fragment "example/best-practices.html#cs"}}        {{!-- "cs" --}}
<h1 id="{{#fragment model.url}}">{{model.name}}</h1>