CARVIEW |
Select Language
HTTP/2 200
access-control-allow-origin: *
age: 0
cache-control: public, max-age=0, must-revalidate
content-disposition: inline; filename="inputpath-to-url"
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Sun, 12 Oct 2025 13:31:04 GMT
etag: W/"bf0c43340143d42a3a870018bb4b8281"
last-modified: Sun, 12 Oct 2025 13:31:04 GMT
server: Vercel
strict-transport-security: max-age=63072000
x-vercel-cache: HIT
x-vercel-id: bom1::xnntw-1760275864051-45b3ade17ce7
inputPathToUrl Filter — Eleventy
- Stable
3.1.2
- Canary
4.0.0-alpha.4
- Guide
Guide
- Plugins
- Services
inputPathToUrl
Universal Filter
Added in v3.0.0 Map a file’s location and to the template’s output URL. Very useful for robust hyperlinking allowing you to change your output URLs without breaking content links! Eleventy 3.0 memoizes this filter.
INFO:
This filter is an alternative to the InputPath To Url Plugin, which provides an Eleventy transform that is less verbose but a bit slower.
Inspired by GitHub issue #84.
Usage
<a href="{{ "index.md" | inputPathToUrl }}">Home</a>
<a href="{{ "index.md" | inputPathToUrl }}">Home</a>
export default function (data) {
return `<a href="${this.inputPathToUrl("index.md")}">Home</a>`;
}
module.exports = function (data) {
return `<a href="${this.inputPathToUrl("index.md")}">Home</a>`;
};
Renders as <a href="/">Home</a>
.
- The paths used here should be relative to the input directory though they can be relative to the project root (the former is simpler and more robust).
- If an
inputPath
match can not be found, this filter will throw an error. - When pointing to a Pagination template, the first URL in the pagination set is returned.
← Back to Filters documentation.