Listings, feeds and URLs
Pagination, tag pages and Atom feeds come from tables on a model. A site with a URL gets a sitemap; templates/404.html becomes 404.html. Slug formats and redirects shape URLs.
The examples on this page use a blog: a page /blog with the model blog,
whose children are posts.
# models/blog.toml
[children]
model = "post"
order_by = ["-pub_date"]
[pagination]
per_page = 10
[tags]
field = "tags"
[feed]
limit = 20
[fields.title]
type = "string"
# models/post.toml
[fields.title]
type = "string"
[fields.pub_date]
type = "date"
[fields.tags]
type = "strings"
default = []
[fields.body]
type = "markdown"
body = true
Pagination
A model with a [pagination] table lists its children over several pages.
| Key | Default | Meaning |
|---|---|---|
per_page | 10 | How many children each page lists. At least 1 (motabhai::model::invalid_count). |
url_suffix | "page" | The URL segment before the page number (motabhai::model::invalid_url_segment if it is not one clean segment). |
Page 1 is the page itself, /blog/. Page 2 and on are at
/blog/page/2/, /blog/page/3/ and so on, all rendered with the page's
template. The children are those the default children query lists, in
its order, so hidden and undiscoverable ones are left out. A page with no
children still has page 1. Pages appear and disappear as children come and
go.
On these pages this.pagination has:
| Attribute | Value |
|---|---|
page | This page's number, from 1. |
pages | How many pages there are. |
per_page | The per_page setting. |
total | How many children there are in all. |
items | This page's children, as a query. |
prev, next | The previous and next page, each with page and url_path, or none at the ends. url links to either. |
this.pagination is undefined on pages whose model has no
[pagination].
{% for post in this.pagination.items %}
<h2><a href="{{ post|url }}">{{ post.title }}</a></h2>
{% endfor %}
<nav>
{% if this.pagination.prev %}<a href="{{ this.pagination.prev|url }}">Newer</a>{% endif %}
Page {{ this.pagination.page }} of {{ this.pagination.pages }}
{% if this.pagination.next %}<a href="{{ this.pagination.next|url }}">Older</a>{% endif %}
</nav>
Relative links on page n resolve against that page's URL. There is no
list of every page for numbered navigation yet; build one from pages if
you need it.
Tag pages
A model with a [tags] table gets a page for each tag its children use.
| Key | Default | Meaning |
|---|---|---|
field | "tags" | The children's field holding their tags: a strings or checkboxes field (motabhai::model::invalid_field_name if it is not a field name). |
template | "tag.html" | The template of each tag page. It must not be empty (motabhai::model::empty_template). |
url_suffix | "tag" | The URL segment before the tag (motabhai::model::invalid_url_segment if it is not one clean segment). |
Each tag page is at <page URL><url_suffix>/<tag>/, with the tag made into
a slug: the tag Static Sites of /blog is at /blog/tag/static-sites/.
A tag with no letters or digits is used as it is.
Only children that the default children query lists count, so hidden and
undiscoverable posts add no tags. A tag no child has any more loses its
page.
In the tag template, this is the parent page (the blog), and tag has
name, url_path and items, a query of the children with the tag. It
prints as its name:
{# templates/tag.html #}
{% extends "layout.html" %}
{% block body %}
<h1>Posts tagged “{{ tag.name }}”</h1>
{% for post in tag.items %}
<a href="{{ post|url }}">{{ post.title }}</a>
{% endfor %}
{% endblock %}
The parent lists its tags as this.tag_pages, sorted alphabetically
ignoring case, and tag_page("rust") finds one. url links to either:
{# on the blog #}
{% for tag in this.tag_pages %}<a href="{{ tag|url }}">{{ tag.name }}</a>{% endfor %}
{# on a post #}
{% for tag in this.tags %}<a href="{{ this.parent.tag_page(tag)|url }}">{{ tag }}</a>{% endfor %}
Calling tag_page on a page whose model has no [tags] is
motabhai::template::no_tag_pages, and this.tag_pages is undefined
there. Tag pages are not paginated, and two
tags that make the same slug, such as Rust and rust, collide as
motabhai::build::output_conflict.
Atom feeds
A model with a [feed] table gets an Atom feed of its children, written by
motabhai rather than a template.
| Key | Default | Meaning |
|---|---|---|
filename | "feed.xml" | The file name, beside the page: /blog/feed.xml. One URL segment (motabhai::model::invalid_url_segment). |
title | the page's title field, else the site name | The feed title. |
limit | 20 | The most entries the feed holds. At least 1 (motabhai::model::invalid_count). |
item_title | "title" | The children's field holding each entry's title. |
item_body | "body" | The children's field holding each entry's content. |
item_date | "pub_date" | The children's date or datetime field giving each entry's date. |
The three item_ keys take field names
(motabhai::model::invalid_field_name).
Entries are the children that have a date, in the default children
order, up to limit; hidden and undiscoverable children are left out. A
date counts as midnight UTC, and a date-time without an offset as UTC. The
feed's own date is that of its newest entry, and its author is the site
name. An entry's content is its body as HTML: Markdown is rendered, HTML
is used as it is, and plain text is escaped. An entry with no body has no
content. Links in the feed are absolute, so the site needs a project.url
(motabhai::model::feed_without_url). Each language gets its own feed.
Link to it from your layout:
<link rel="alternate" type="application/atom+xml" href="{{ '/blog/feed.xml'|url }}">
Sitemap
A site with a project.url gets sitemap.xml at its root. It lists every
built, discoverable page in every language, then each one's tag pages; on a
multilingual site each URL carries links to its translations. Further
pages of paginated lists are left out. Turn it off with:
[sitemap]
enabled = false
The 404 page
If templates/404.html exists, it is built to 404.html at the root of
the output, with the root page as this. GitHub Pages, and most static
hosts, serve that file for missing pages, and so does motabhai serve.
{% extends "layout.html" %}
{% block body %}
<h1>Page not found</h1>
<p><a href="{{ site.root|url }}">Back to the home page</a></p>
{% endblock %}
Slug formats
A parent model's children.slug_format gives its children their URLs, for
example by date:
# models/blog.toml
[children]
model = "post"
slug_format = "{pub_date:%Y/%m}/{_id}"
The post content/blog/hello/index.md with pub_date = 2026-11-29 is
then served at /blog/2026/11/hello/.
A format is text with fields of the child in braces:
- A
dateordatetimefield takes a strftime format after:; without one it is the ISO 8601 date:{pub_date}gives2026-11-29. - Any other field is made into a slug:
{title}with the titleHello, World!giveshello-world. Letters and digits are kept, in lower case; spaces and separators such as-,_,.,,and/become one-, and anything else is dropped. _idis used as it is. It is the only system field a format can use.
| Format | URL of the post first |
|---|---|
{_id} | /blog/first/ |
{pub_date}-{_id} | /blog/2026-03-04-first/ |
{pub_date:%Y}/{_id} | /blog/2026/first/ |
post-{title} | /blog/post-grüße-aus-köln/ for the title Grüße aus Köln |
A format needs at least one field and balanced braces
(motabhai::model::invalid_slug_format). A child without a field its
format needs, a strftime format on a field that is not a date, or a result
that is not a valid slug, is motabhai::content::invalid_slug_format. A
child's own _slug wins over the format. Formats apply to direct children
only.
Redirects
When a page moves, list its old URLs in _redirect_from, and each gets a
page that redirects to the new one:
_redirect_from = ["/about-us/", "/old/about.html"]
See Content files for the rules. Moving a page in the admin UI does not add these for you.