Models and field types

A model declares a page's fields, their types and defaults, and how the page's children and attachments behave.

Every page has a model: a TOML file in models/, named after the model's ID. models/blog-post.toml is the model blog-post. IDs use lowercase letters, digits, - and _, and start with a letter or a digit (motabhai::model::invalid_id). Files in models/ that do not end in .toml, or whose names start with a dot, are ignored.

Every table and key of a model is optional, so an empty file is a valid model. A table or key that is not described here, such as a misspelt requird, is motabhai::toml. A page that does not say which model it uses gets one from its parent, or else the model page; see Content files.

A complete model

[model]
label = "Blog"               # defaults to the humanised ID: "Blog"
template = "blog.html"       # defaults to "<id>.html"

[children]
enabled = true               # whether these pages may have children
model = "blog-post"          # the model of children that do not set _model
allowed_models = ["blog-post"]
order_by = ["-pub_date", "title"]
hidden = false               # whether children are hidden by default
slug_format = "{pub_date:%Y/%m}/{_id}"

[attachments]
enabled = true

[pagination]
per_page = 10

[tags]
field = "tags"

[feed]
title = "My blog"

[fields.title]
type = "string"
label = "Title"
required = true

[fields.body]
type = "markdown"
body = true

[pagination], [tags] and [feed] are described in Listings, feeds and URLs.

[model]

KeyDefaultMeaning
labelthe humanised ID (blog-post becomes "Blog post")The name the admin UI shows.
template<id>.htmlThe template pages of this model render with, unless they set _template. It must not be empty (motabhai::model::empty_template).
formats["markdown"]The content file formats pages of this model may use: "markdown" for index.md, "notebook" for a Jupyter notebook, index.ipynb. A non-empty list of those two, without repeats (motabhai::model::invalid_formats). A page in a format the model does not list is motabhai::content::format_not_allowed.

A model that lists "notebook" needs a markdown field with body = true, which receives the notebook's cells (motabhai::model::notebook_needs_body), and cannot have flow fields (motabhai::model::notebook_with_flow).

[model]
formats = ["markdown", "notebook"]

[fields.body]
type = "markdown"
body = true

Fields

Each [fields.<name>] table declares one field. Fields keep the order they are written in, which is also the order of the admin UI's form.

Field names start with a lowercase letter and use lowercase letters, digits and _ (motabhai::model::invalid_field_name). Names starting with _ are system fields. These names are reserved for what templates read from every page, so no field can use them (motabhai::model::reserved_field_name): parent, children, attachments, url_path, prev, next, alternatives, pagination and tag_pages.

KeyMeaning
typeRequired. One of the types below (motabhai::model::unknown_field_type).
labelThe label in the admin UI. Defaults to the humanised name: pub_date becomes "Pub date".
descriptionHelp text shown under the field in the admin UI.
requiredtrue if every page must set the field (motabhai::content::missing_field). A required field cannot also have a default (motabhai::model::required_with_default).
defaultThe value a page gets when it leaves the field out. It must be a valid value of the field's type (motabhai::model::invalid_default). A flow field has none.
bodytrue for the one field that receives the Markdown after the front matter.
choicesFor select and checkboxes: the allowed values, a list of strings. Those types need a non-empty list (motabhai::model::missing_choices), and no other type takes one (motabhai::model::unexpected_choices).
blocksFor flow only: the flow block models the field allows. All of them if left out. See Flow blocks.

A field that a page leaves out, with no default, has no value: templates see none, which prints as nothing.

Field types

Values are written in the front matter as TOML, and checked against the type when the site loads. A value of the wrong TOML type is motabhai::field::wrong_type.

TypeTOML valueIn templates
stringA string on one line (motabhai::field::multiline otherwise)Text, escaped
textA string, may span linesText, escaped
markdownA string of MarkdownHTML, rendered when the template reads it
htmlA string of HTMLHTML, not escaped
integerAn integer such as -42A number
floatA number such as 1.5; integers are acceptedA number
booleantrue or falseA boolean
dateA TOML local date, without a time: 2026-11-29, not quotedISO 8601 text, for dateformat
datetimeA TOML date-time, with a date and a time, with or without an offset: 2026-11-29T09:30:00+01:00ISO 8601 text
urlA URL or a link such as "https://example.com" or "/about/": not empty, no whitespace (motabhai::field::invalid_url)Text; pass it through the url filter for a link
selectOne string out of choices (motabhai::field::invalid_choice)Text
checkboxesA list of distinct strings out of choices (motabhai::field::duplicate_choice)A list
stringsA list of strings, such as tagsA list
flowAn array of tables, one per block; see Flow blocksThe rendered blocks
[fields.kind]
type = "select"
choices = ["note", "essay"]
default = "note"

[fields.flags]
type = "checkboxes"
choices = ["draft", "pinned"]

[fields.tags]
type = "strings"
default = []

The body field

The text after a content file's front matter goes to the field marked body = true. Only one field may be the body (motabhai::model::multiple_body_fields), it must be of type text, markdown or html (motabhai::model::invalid_body_type), and it cannot have a default (motabhai::model::body_with_default).

A model without a body field takes no body: text after the front matter is motabhai::content::unexpected_body. Setting the body field inside the front matter is motabhai::content::body_in_front_matter.

[children]

How the children of pages with this model behave.

KeyDefaultMeaning
enabledtrueWhether pages with this model may have children at all (motabhai::content::children_not_allowed).
modelnoneThe model of children that do not set _model. It must be one of allowed_models, if those are given (motabhai::model::default_not_allowed).
allowed_modelsanyThe only models children may use (motabhai::content::model_not_allowed).
order_by_id orderThe default order of this.children: field names, each with a leading - for descending order (motabhai::model::invalid_order_by for anything else). The system fields _id, _path, _alt, _model, _template, _slug, _hidden, _discoverable and _created may be used.
hiddenfalseWhether children are hidden unless they set _hidden = false.
slug_formatthe child's _idHow children that do not set _slug get their URL; see Listings, feeds and URLs.

model and allowed_models must name models that exist (motabhai::model::unknown_model).

Ordering compares values of the field's type; pages without the field come first. Ties keep _id order.

[attachments]

KeyDefaultMeaning
enabledtrueWhether pages with this model may have attachments: files other than content files in the page's directory (motabhai::content::attachments_not_allowed).

When a model is broken

Every problem in every model is reported in one go, each with its file, line and column. Pages that use a model that failed to load are not checked against it, so one mistake in a model does not cause an error for every page.