Project layout and motabhai.toml
The directories of a motabhai project, and every table and key of its config file.
A project on disk
A project is a directory with a motabhai.toml file in it. Everything
else is optional, though a site needs at least a root page and a model for
it.
mysite/
motabhai.toml # the site config: this page
models/ # one TOML file per page model
page.toml
blog-post.toml
flowblocks/ # one TOML file per flow block model
image.toml
content/ # one directory per page
index.md # the root page
blog/
index.md
first-post/
index.md # TOML front matter, then the Markdown body
index.de.md # the German translation
hero.jpg # an attachment
templates/ # MiniJinja templates
layout.html
page.html
blocks/image.html # a flow block's template
404.html # built to 404.html, if present
databags/ # data any template can read with bag()
menu.toml
assets/ # copied to the root of the output
css/main.css # stylesheets are bundled, minified and fingerprinted
themes/ # installed themes
plain/ # a theme: its own templates/ and assets/
.motabhai/ # build state; not content
public/ # the default output directory
| Directory | What it holds | Described in |
|---|---|---|
models/ | Page models: fields and how children behave | Models and fields |
flowblocks/ | Flow block models | Flow blocks |
content/ | The pages, their translations and attachments | Content files |
templates/ | Templates for pages, blocks, tag pages and the 404 page | Templates |
databags/ | TOML files read with bag("name") | Templates |
assets/ | Stylesheets, scripts, images and other static files | Assets and images |
themes/ | Themes: templates and assets the site's own are laid over | Themes |
Files and directories whose names start with a dot are ignored everywhere,
so editor and macOS leftovers such as ._page.toml do no harm.
Build output goes to public/ unless you pass --output. Build state, a
cache of what the last build made from what, goes to .motabhai/. Both
belong in .gitignore, and motabhai new adds them. The output directory
may not be the project root, a directory above it, or a source directory
such as content/ or anything inside one
(motabhai::build::unsafe_output), because a build removes whatever in it
the build did not make.
Finding the project
Every command looks for motabhai.toml in the current directory and then
in each parent, so you can run them from anywhere inside a project. To
name the project instead, pass -p/--project with its directory or its
motabhai.toml:
motabhai build --project docs
An explicit directory is not searched upward. Outside any project, commands
fail with motabhai::project::not_found.
motabhai.toml
The config is TOML. Only [project] and its name are required. Unknown
tables and keys are errors (motabhai::toml), so a typo is reported rather
than silently ignored, and every problem is reported with its line and
column.
A complete example:
[project]
name = "My Site"
url = "https://user.github.io/my-site/"
language = "en"
theme = "plain"
[css]
browsers = ["defaults", "safari >= 15"]
minify = true
fingerprint = true
[tailwind]
version = "4.3.5"
input = "css/main.css"
[alternatives.en]
name = "English"
[alternatives.de]
name = "Deutsch"
url_prefix = "/de/"
[notebook]
kernel = "python3"
language = "python"
execute = false
jupyter = "jupyter"
timeout = 600
[sitemap]
enabled = true
[deploy.github-pages]
type = "github-pages"
[hooks]
after_build = ["npx pagefind --site \"$MOTABHAI_OUTPUT\""]
[project]
| Key | Type | Default | Meaning |
|---|---|---|---|
name | string | required | The site name, shown in templates as config.name. Must not be empty (motabhai::config::empty_name). |
url | string | none | The absolute http or https URL the site is published at. A trailing / is added if missing. It may not have a query or fragment (motabhai::config::invalid_url). |
language | string | "en" | The primary language of the content, as a language tag such as en, pt-BR or zh-Hant-TW (motabhai::config::invalid_language otherwise). |
theme | string | none | The theme in use: the name of a directory of themes/. Without it the site uses only its own templates/ and assets/. A name is letters, digits, -, _ and ., and does not start with a . (motabhai::config::invalid_theme); a theme that is not installed is motabhai::config::unknown_theme. The admin's "Themes" page rewrites this key. |
url matters in three ways:
- The base path. Its path, such as
/my-site/inhttps://user.github.io/my-site/, is the base path. Every link made with theurlandasseturlfilters, and every relative link in Markdown, starts with it, andmotabhai serveserves the site under it. Without aurlthe base path is/. - Absolute links. Atom feeds and the sitemap need absolute URLs, so a
model with a
[feed]table on a site without aurlis an error (motabhai::model::feed_without_url), and nositemap.xmlis built. - Templates can read it as
config.urlandconfig.base_path.
[css]
How stylesheets in assets/ are processed. See
Assets and images.
| Key | Type | Default | Meaning |
|---|---|---|---|
browsers | list of strings | ["defaults"] | Browserslist queries naming the browsers to support. Vendor prefixes are added, and newer syntax such as nesting is rewritten, for exactly these. The list must not be empty, and each entry must be a query Browserslist knows (motabhai::config::invalid_browsers). |
minify | boolean | true | Whether stylesheets are minified. |
fingerprint | boolean | true | Whether built stylesheets get a hash of their content in their file name, such as css/main.3f2a9c1b.css. |
[tailwind]
Present only for sites that use Tailwind CSS. See Assets and images.
| Key | Type | Default | Meaning |
|---|---|---|---|
version | string | required | The pinned Tailwind CSS version: an exact version of Tailwind CSS 4 or later, such as "4.3.5", or a pre-release such as "4.0.0-beta.3". Ranges, latest and version 3 are refused (motabhai::config::invalid_tailwind_version). |
input | string | "css/main.css" | The stylesheet Tailwind compiles, as a .css path inside assets/ (motabhai::config::invalid_tailwind_input otherwise). If the site's assets/ has no such file, the theme's is compiled. |
[alternatives.<code>]
One table per language of the content. The table name is the language tag
(motabhai::config::invalid_language if it is not one).
See Translations.
| Key | Type | Default | Meaning |
|---|---|---|---|
name | string | the code | The language's name, for a language switcher, such as "Deutsch". |
url_prefix | string | / for the primary language, /<code>/ otherwise | The URL path the language is served under. It starts and ends with / (motabhai::config::invalid_url_prefix). Two languages cannot share one (motabhai::config::duplicate_url_prefix). |
The primary language is project.language. It may have a table too, to
give it a name or move it under a prefix.
[notebook]
What a new notebook post starts with when the admin creates a blank one, and how notebooks are run. See Content files for notebook pages and Notebook posts for running them.
| Key | Type | Default | Meaning |
|---|---|---|---|
kernel | string | "python3" | The kernelspec name written into a new notebook. |
language | string | "python" | The language of the new notebook's code cells. |
execute | boolean | false | Turns on running cells from the admin, on a dev server listening on loopback; it is off because running a cell executes code as your user. See Running cells in the admin. It does not affect motabhai build --execute, which is always allowed. |
jupyter | string | "jupyter" | The Jupyter program to run: a command on the PATH, or a path to one (a relative path, such as .venv/bin/jupyter, is relative to the project root). motabhai build --execute runs notebooks with its nbconvert; the admin runs cells with its jupyter server. |
timeout | integer | 600 | How many seconds one cell may run before it is stopped. |
An empty kernel, language or jupyter, or a timeout that is not
greater than 0, is motabhai::config::invalid_notebook. A value of the
wrong type, such as timeout = "slow", is motabhai::toml, as is a key not
listed here.
[sitemap]
| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | boolean | true | Whether to build sitemap.xml. It is only built for a site with a project.url. |
[deploy.<name>]
One table per place the site is published to. The table's name is the
target motabhai deploy <name> takes, and its type is github-pages,
rsync or s3 (motabhai::config::invalid_deploy_type otherwise). Each
type takes only its own keys (motabhai::config::invalid_deploy_key).
Deploying describes what each type does.
type = "github-pages":
| Key | Type | Default | Meaning |
|---|---|---|---|
remote | string | "origin" | A remote of the project's git repository, or a repository URL or path. |
branch | string | "gh-pages" | The branch to commit to. |
cname | string | none | A custom domain, such as "www.example.com" without https://, written to a CNAME file. |
type = "rsync":
| Key | Type | Default | Meaning |
|---|---|---|---|
target | string | required | The destination, such as "me@example.com:/var/www/site" or a local directory. |
delete | boolean | true | Whether files the output no longer has are removed from the destination. |
args | list of strings | [] | Further arguments for rsync. |
type = "s3":
| Key | Type | Default | Meaning |
|---|---|---|---|
bucket | string | required | The bucket's name. |
region | string | "us-east-1" | The bucket's region. |
endpoint | string | none | The http or https URL of a service other than Amazon S3 with the same API. The bucket is then addressed by path. |
prefix | string | none | The start of every key, to keep the site in part of the bucket. Slashes at its start and end are optional. |
delete | boolean | true | Whether objects under the prefix that the output no longer has are deleted. |
A missing target or bucket is motabhai::config::missing_deploy_key,
and a value that is empty or malformed is
motabhai::config::invalid_deploy_value.
[hooks]
Shell commands run around motabhai build and motabhai deploy, but not
by motabhai serve. See Build hooks.
| Key | Type | Default | Meaning |
|---|---|---|---|
before_build | list of strings | [] | Commands run in order before the site is built. |
after_build | list of strings | [] | Commands run in order after the site is built. |