API reference
Templates – quick reference
Page HTML, head and snippets are pongo2 templates (similar to Django/Twig). Output with {{ … }} is automatically HTML-escaped.
| Variable / function | Description |
|---|---|
page.id, .title, .meta_title, .slug, .path, .description, .parent_id |
Current page (meta_title and description already evaluated) |
page.noindex, page.nofollow |
Robots settings of the page (bool) |
page.lang |
Effective language of the page (own, inherited or de) |
site.id, .title, .domain, .domains, .favicon |
Current website (its root page); domain = first registered domain, favicon = URL of the website icon or empty |
route.path |
Requested path |
route.slug / route.rest |
Subpath for catch-all pages as a string or a list of segments |
route.query.x |
Query parameter ?x=… |
today |
Today’s date (JJJJ-MM-TT, server time) – for date comparisons in data() |
now |
Current point in time (for |date) |
preview |
true in the admin preview |
data("slug", "k1", v1, "k2", v2, …) |
Collection or REST source, parameters as key/value pairs (as with /data) |
item("slug", "feld", wert, …) |
First entry with feld == wert or nil |
translations() / translations(entry) |
Published language versions of the page or of an entry for language switchers: list of { lang, title, url, current }, sorted by language code; url relative (own website) or absolute (other website with a domain). Without a group only the current page. Including drafts in the preview |
language_name(code) |
Native name of a language: de → “Deutsch”, fr → “Français”, de-at → “Deutsch (AT)”; unknown codes unchanged |
nav() |
Published subpages of the home page of the current website |
children() / children(id) |
Published subpages of the current / a specific page |
lang_root() / lang_root(id) |
Home page of the language tree of the current / a specific page: the page itself or the nearest ancestor with its own lang, otherwise the website’s home page; same fields as nav() (id, title, path, lang …). Menu per language: children(lang_root().id) |
image(id, sizes?, class?) |
Responsive <img> with srcset, alt text and dimensions |
file(id) |
{ url, srcset, name, mime, size, width, height, alt } |
{% include "snippet-name" %} |
Include a snippet, optionally with key=value |
{% component "name" key=wert %}…{% endcomponent %} |
Snippet as a component with content; {% fill "slot" %}…{% endfill %} fills named slots, the rest fills the default slot. In the snippet: {% slot %}/{% slot "name" %}Fallback{% endslot %}, slots.name |
{% extends "layout" %} + {% block x %}…{% endblock %} |
Page based on a layout snippet (must be at the beginning) |
{% verbatim %}…{% endverbatim %} |
Content is output unchanged, {{ … }} inside is not evaluated (e.g. for Vue/Handlebars). Also works in snippets |
not_found() |
Aborts rendering and returns the 404 page with status 404 – the website’s 404 page (notfound_page_id, otherwise the page with slug 404 below the home page, otherwise a default page) |
asset_url(id) |
Versioned URL of a CSS/JS file, e.g. <script src="{{ asset_url(7) }}"> – if a file should be loaded at a specific position instead of via the page assignment |
|json |
Output a value as JSON |
|markdown |
Markdown to HTML (GitHub Flavored: tables, task lists, strikethrough, autolinks; headings get ids, umlauts transliterated: „Über uns“ → ueber-uns). For security reasons, raw HTML in Markdown is not output – |markdown:"html" lets it through (only for your own texts). As a block: {% filter markdown %}…{% endfilter %} |
Whitespace is output exactly as it appears in the template (as in Twig) – tags remove neither line breaks nor spaces.
Example of a blog page with catch-all (/blog and /blog/<slug>), SEO title {% if route.slug %}{{ item("blog", "slug", route.slug).titel }} – {% endif %}Blog:
{% include "header" %}
{% if route.slug %}
{% with post=item("blog", "slug", route.slug) %}
{% if not post %}{{ not_found() }}{% endif %}
<article>
<h1>{{ post.titel }}</h1>
{{ image(post.bild, "(min-width: 900px) 60vw, 100vw") }}
{{ post.text|markdown }}
</article>
{% endwith %}
{% else %}
{% for post in data("blog", "sort", "-datum", "limit", 10) %}
<a href="/blog/{{ post.slug }}">{{ post.titel }}</a>
{% endfor %}
{% endif %}
The complete cheat sheet can be found in the HTML editor under Template help; detailed explanations and recipes are in the manual.