URL Installed

Provide the url filter to fix and resolve URLs.

Options See on deno.land

names object

The url helper name

url string
htmlUrl string


This plugin provides the url and htmlUrl filters to fix the page URLs in the pages and layouts.


This plugin is installed by default. 🎉

url filter

The filter url normalizes a single path with the location value that you have configured in _config.js. It's useful if your site is in a subdirectory or you want to generate absolute URLs.

<a href="{{ '/about-us' | url }}">

<!-- Full URL -->
<a href="{{ '/about-us' | url(true) }}">

If you don't want to use this filter everywhere, you may be interested in the Base path plugin {.tip}

Urls from source files

Use the character ~ to use the source file name instead of the final URL. The plugin automatically will detect the final URL for you. This is useful for dynamic URLs and automatically updating all links to a page when the URL of this page changes. For example:

<a href="{{ '~/about-us.md' | url }}">

<!-- Will be converted to -->
<a href="/about-us/">

Some source files can generate multiple pages. You can include a query after the file name to select the specific page generated by the source file. For example:

<a href="{{ '~/about-us.tmpl.js(lang=en)' | url }}">

<!-- Will be converted to -->
<a href="/en/about-us/">

In the previous example, the (lang=en) query select the page with the lang variable set to en among all pages generated by about-us.tmpl.js file.

htmlUrl filter

This filter is similar to url but it works with HTML code: it searches and normalizes all URLs found in href and src attributes:

text: 'Go to <a href="/">Homepage</a>'
<div>{{ text | htmlUrl | safe }}</div>