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
DirectoryWhat it holdsDescribed in
models/Page models: fields and how children behaveModels and fields
flowblocks/Flow block modelsFlow blocks
content/The pages, their translations and attachmentsContent files
templates/Templates for pages, blocks, tag pages and the 404 pageTemplates
databags/TOML files read with bag("name")Templates
assets/Stylesheets, scripts, images and other static filesAssets and images
themes/Themes: templates and assets the site's own are laid overThemes

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]

KeyTypeDefaultMeaning
namestringrequiredThe site name, shown in templates as config.name. Must not be empty (motabhai::config::empty_name).
urlstringnoneThe 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).
languagestring"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).
themestringnoneThe 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/ in https://user.github.io/my-site/, is the base path. Every link made with the url and asseturl filters, and every relative link in Markdown, starts with it, and motabhai serve serves the site under it. Without a url the base path is /.
  • Absolute links. Atom feeds and the sitemap need absolute URLs, so a model with a [feed] table on a site without a url is an error (motabhai::model::feed_without_url), and no sitemap.xml is built.
  • Templates can read it as config.url and config.base_path.

[css]

How stylesheets in assets/ are processed. See Assets and images.

KeyTypeDefaultMeaning
browserslist 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).
minifybooleantrueWhether stylesheets are minified.
fingerprintbooleantrueWhether 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.

KeyTypeDefaultMeaning
versionstringrequiredThe 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).
inputstring"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.

KeyTypeDefaultMeaning
namestringthe codeThe language's name, for a language switcher, such as "Deutsch".
url_prefixstring/ for the primary language, /<code>/ otherwiseThe 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.

KeyTypeDefaultMeaning
kernelstring"python3"The kernelspec name written into a new notebook.
languagestring"python"The language of the new notebook's code cells.
executebooleanfalseTurns 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.
jupyterstring"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.
timeoutinteger600How 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]

KeyTypeDefaultMeaning
enabledbooleantrueWhether 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":

KeyTypeDefaultMeaning
remotestring"origin"A remote of the project's git repository, or a repository URL or path.
branchstring"gh-pages"The branch to commit to.
cnamestringnoneA custom domain, such as "www.example.com" without https://, written to a CNAME file.

type = "rsync":

KeyTypeDefaultMeaning
targetstringrequiredThe destination, such as "me@example.com:/var/www/site" or a local directory.
deletebooleantrueWhether files the output no longer has are removed from the destination.
argslist of strings[]Further arguments for rsync.

type = "s3":

KeyTypeDefaultMeaning
bucketstringrequiredThe bucket's name.
regionstring"us-east-1"The bucket's region.
endpointstringnoneThe http or https URL of a service other than Amazon S3 with the same API. The bucket is then addressed by path.
prefixstringnoneThe start of every key, to keep the site in part of the bucket. Slashes at its start and end are optional.
deletebooleantrueWhether 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.

KeyTypeDefaultMeaning
before_buildlist of strings[]Commands run in order before the site is built.
after_buildlist of strings[]Commands run in order after the site is built.