Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Functions

A function is called in {{ }} and gives a URL, a rendered partial, a content block or a component’s markup.

<a href="{{ page('blog/post', slug=post.slug) }}">{{ post.title }}</a>
{{ partial("card.htm", title="Acme", body=page.body) }}
{{ content("intro.md") }}
<link rel="stylesheet" href="{{ asset('css/site.css') }}">
<link rel="canonical" href="{{ url(this.url) }}">
<img src="{{ media(post.image, preset='card') }}">
{{ component('latest') }}
NameGives
page(<name>, param=value, ...)The URL of the page named by its path without the extension; a parameter left out takes its default (see Pages).
partial(<path>, name=value, ...)A partial with the named variables, the request’s this and head, and the globals.
content(<path>, name=value, ...)A content block: .md rendered to HTML, .htm and .html as they are, anything else escaped as text; {name} in the block is the named variable, escaped (see Content).
asset(<path>)The URL of the theme’s text asset: /themes/<code>/assets/<path>.
url(<path>)The absolute URL of a path on the site, from the deployment’s origin.
media(<file>), media(<file>, preset="card")The URL of a media value (a URL, or an object with url as theme::media_value builds), under a preset when one is named.
component(<alias>)The theme’s partials/<alias>/default.htm, else the component’s own markup, with the data as component and under the alias, beside this and head (see Components).
framework()The request framework’s script and its island (see Interactive Pages).
request(<handler>, target=, swap=, partial=, confirm=, indicator=)The attributes that post a form or element to a component’s handler, with the visitor’s token.
token(<handler>)The hidden fields a form posts to a handler without a script.
colour_mode(), colour_mode(file=true)The colour mode script, inline or as a file (see Colour Mode).

Add a function from a module

impl Markup for Money {
    fn install(&self, env: &mut Environment<'static>) {
        env.add_function("year", || 2026);
    }
}
{{ year() }}

The registration is described under Templating. A static build sets the origin url() uses with --base-url.