Zorto registers custom template functions, filters, and tests on top of the Tera template engine. This page is the complete reference.

Functions #

Functions are called with named arguments inside templates.

get_url #

Returns the full permalink for a content path or static file.

Signature: get_url(path)

ArgumentTypeDescription
pathstringContent path (@/ prefix), static file path, or external URL

Content paths use the @/ prefix to reference files in the content/ directory:

{{ get_url(path="posts/hello.md") }}
<!-- https://example.com/posts/hello/ -->

{{ get_url(path="posts/_index.md") }}
<!-- https://example.com/posts/ -->

In content files, prefix paths with @/ for build-time link validation.

Static file paths are resolved relative to the site root:

{{ get_url(path="/img/photo.png") }}
<!-- https://example.com/img/photo.png -->

External URLs are returned as-is:

{{ get_url(path="https://github.com") }}
<!-- https://github.com -->

get_section #

Loads a section object by its _index.md path. Returns the full section with its pages, useful for cross-referencing content.

Signature: get_section(path)

ArgumentTypeDescription
pathstringRelative path to the section’s _index.md
{% set posts = get_section(path="posts/_index.md") %}
{% for page in posts.pages %}
  <a href="{{ page.permalink }}">{{ page.title }}</a>
{% endfor %}

The returned section object has all the fields documented in the frontmatter reference (title, pages, path, permalink, extra, etc.).

Warning

get_section raises an error if the path does not match any loaded section. Double-check the path matches the actual _index.md location.

get_taxonomy_url #

Returns the permalink for a specific taxonomy term page.

Signature: get_taxonomy_url(kind, name)

ArgumentTypeDescription
kindstringTaxonomy name (e.g. "tags", "categories")
namestringTerm value (e.g. "rust")
{{ get_taxonomy_url(kind="tags", name="rust") }}
<!-- https://example.com/tags/rust/ -->

The term name is slugified to form the URL (e.g. "My Tag" becomes my-tag).

now #

Returns the current local timestamp as a string in YYYY-MM-DDTHH:MM:SS format.

Signature: now()

<footer>Built at {{ now() }}</footer>
<!-- Built at 2026-04-04T14:30:00 -->

Filters #

Filters transform values using the pipe (|) syntax. Zorto provides these custom filters in addition to Tera’s built-in filters.

date #

Formats a date string using chrono format specifiers.

ParameterTypeDefaultDescription
formatstring"%Y-%m-%d"Output format string

Accepts YYYY-MM-DD and YYYY-MM-DDTHH:MM:SS input formats. Returns the original string unchanged if parsing fails.

{{ page.date | date(format="%B %d, %Y") }}
<!-- June 15, 2025 -->

{{ page.date | date(format="%Y") }}
<!-- 2025 -->

pluralize #

Returns "s" when the value is not 1, empty string when it is 1. Useful for English pluralization.

{{ count }} item{{ count | pluralize }}
<!-- "1 item" or "5 items" -->

Works with integers and floats (floats are truncated to integers).

slice #

Extracts a sub-array from an array.

ParameterTypeDefaultDescription
startint0Start index (inclusive)
endintarray lengthEnd index (exclusive)
{% for page in section.pages | slice(end=5) %}
  <!-- First 5 pages -->
{% endfor %}

{% for page in section.pages | slice(start=2, end=7) %}
  <!-- Pages 3 through 7 -->
{% endfor %}

Out-of-bounds values are clamped to the array length.

Tests #

Tests check conditions using the is keyword.

starting_with #

Tests whether a string starts with the given prefix.

{% if page.path is starting_with("/docs") %}
  <!-- Documentation page -->
{% endif %}

Tera built-in filters #

Zorto inherits all of Tera’s built-in filters. Commonly used ones:

FilterDescriptionExample
safeMark HTML as safe (no escaping){{ page.content | safe }}
lengthArray or string length{{ items | length }}
upperUppercase a string{{ title | upper }}
lowerLowercase a string{{ title | lower }}
replaceReplace substring{{ title | replace(from="old", to="new") }}
truncateTruncate string{{ desc | truncate(length=100) }}
defaultFallback value{{ author | default(value="Anonymous") }}
joinJoin array to string{{ tags | join(sep=", ") }}
firstFirst element{{ items | first }}
lastLast element{{ items | last }}
reverseReverse array{{ items | reverse }}
sortSort array{{ items | sort }}
json_encodeSerialize to JSON{{ data | json_encode }}

See the Tera documentation for the complete list.

Further reading #