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

Pages

A page is a template served at its URL; its settings name the URL pattern, the layout, the head’s meta fields and whether it is hidden.

{
  "url": "/blog/:slug",
  "layout": "default",
  "title": "A post",
  "description": "",
  "meta_title": "",
  "meta_description": "",
  "meta_image": "",
  "meta_type": "",
  "meta_robots": "",
  "hidden": false
}
KeyDefaultMeaning
urlrequiredThe URL pattern.
layoutnoneThe layout by name (default for layouts/default.htm); the page then fills its page block, and a block the page defines at its top level fills the layout’s block of that name without rendering in place. A page that writes {% extends %} itself is left as written.
title, description""The page’s own words, read as this.page.title.
meta_title, meta_description, meta_image, meta_type, meta_robots""The head’s meta fields.
hiddenfalseServed only to an operator previewing the theme.
componentsnoneThe components attached to the page, by alias (see Components).

The save refuses a pattern that does not parse or a layout the theme and its ancestors lack.

Write a URL pattern

PatternMatches
/blog/blog, in any case
/blog/:slugone segment, bound to slug
/blog/:slug?the segment or nothing
/blog/:page?1the segment, or 1 when left out
`/blog/:id^[0-9]+$`
/docs/:path*one or more segments, joined with /
/docs/:path?*none or more segments

An optional parameter before a required one is required. One wildcard at most, with no expression and nothing optional after it. The most specific page wins: more static segments, then fewer wildcards, then fewer parameters. The parameters are read as this.params (see Properties).

{% block title %}{{ this.page.title }}{% endblock %}
<a href="{{ page('blog/post', slug=post.slug) }}">{{ post.title }}</a>
NameGives
page(<name>, param=value, ...)The URL of the page named by its path without the extension; a parameter left out takes its default.
{% block page %} in a layoutWhere the page renders (see Layouts and Partials).

The other functions are listed under Functions.

Resolve a URL from Rust

let engine = Engine::build(&db, "acme").await?;
if let Some((name, params)) = engine.resolve("/blog/hello") {
    let settings = engine.page(name);
    let url = engine.url_for(name, &params);
}
for (name, url) in engine.routes().fixed() {
    println!("{name} at {url}");
}

router::Pattern::parse, Pattern::matches, Pattern::url and router::RouteTable are the engine beneath, usable on their own.

Serve the error pages

Page atServes
/404An unmatched URL, with status 404.
/errorA page that failed to render, with status 500.

Hide a page

{ "url": "/drafts", "layout": "default", "hidden": true }

A hidden page is served only to a user previewing their edit theme, and the static build skips it.