Command-line reference
Every motabhai command and option.
motabhai [OPTIONS] <COMMAND>
| Command | What it does |
|---|---|
motabhai new <PATH> | Creates a site from the starter template. |
motabhai check | Loads and validates the project without building it. |
motabhai build | Builds the site into the output directory. |
motabhai serve | Runs the dev server and the admin UI. |
motabhai deploy [TARGET] | Builds the site and deploys it to a target. |
motabhai clean | Removes the build output and the build state. |
motabhai help [COMMAND] | Prints help for motabhai or a command. |
Global options
| Option | Meaning |
|---|---|
-p, --project <PATH> | The project directory, or its motabhai.toml. By default motabhai searches upward from the current directory for motabhai.toml. A directory given here is not searched upward. |
-h, --help | Prints help. |
-V, --version | Prints the version. |
--project can come before or after the command:
motabhai --project docs build and motabhai build --project docs are the
same.
Every command exits with status 0 on success and non-zero on failure.
Errors are printed with their code, such as
motabhai::content::unknown_field, their file, line and column, and the
source around them. Commands that load the site report every problem at
once.
motabhai new
motabhai new [--theme <THEME> | --tailwind] <PATH>
Creates a new site at PATH: a config, models for pages, a blog and
projects, a menu, some content, the themes motabhai ships with
in themes/, a .gitignore, a [deploy.github-pages] target and a
GitHub Actions workflow in .github/workflows/deploy.yml. The site is
named after the directory. The directory may exist if it is empty;
otherwise the command fails with motabhai::new::not_empty and writes
nothing. new makes a project, so --project has no effect on it.
| Option | Meaning |
|---|---|
--theme <THEME> | The theme the site uses: plain, the default, or engineering-fantasy. Both are installed either way, so the site can change between them later. It cannot be combined with --tailwind. |
--tailwind | Styles the starter site with Tailwind CSS, pinned to the latest version this motabhai knows. Its templates and stylesheet are the site's own, in templates/ and assets/, over the plain theme. |
motabhai check
motabhai check
Loads the config, the models and every content file, and reports every problem, without rendering anything. On success it prints a summary:
ok: My Site (/home/me/mysite/motabhai.toml)
3 models, 7 records (1 hidden), 1 attachment
A site with flow blocks or more than one language has them in the summary too:
3 models, 2 flow blocks, 6 records in 2 languages (0 hidden), 1 attachment
Each record is counted once, however many languages it is written in. Template errors are only found by a build.
motabhai build
motabhai build [-o DIR] [--execute]
Runs the before_build hooks, builds the site, then runs the after_build
hooks. The build is incremental: it redoes only the outputs whose inputs
changed since the last build into the same directory, and removes outputs
whose source is gone. It prints what the output holds and how much of it
was redone, with redirects, thumbnails and removed files counted too when
there are any:
built 7 pages, 0 attachments and 1 asset into public (8 rebuilt)
| Option | Meaning |
|---|---|
-o, --output <DIR> | The output directory. Defaults to public in the project root. A relative path is relative to the current directory, not the project. |
--execute | Run every notebook post from a fresh kernel before building and publish the fresh outputs. The notebook files are not changed. Needs Jupyter; see Running notebooks when building. Only build takes it: serve and deploy refuse it. |
The output directory cannot be the project root, a directory above it, or
a source directory such as content/ or anything inside one
(motabhai::build::unsafe_output). Content
errors stop the build before anything is written.
motabhai serve
motabhai serve [--port PORT] [--host ADDRESS] [-o DIR]
Builds the site, serves it, rebuilds when files change and reloads the
browser, and serves the admin UI at /admin/. Hooks are not run. The
site is served under its base path, the path of url in motabhai.toml.
See Dev server and The admin UI.
It prints where it listens:
serving at http://127.0.0.1:5000/
admin at http://127.0.0.1:5000/admin/
| Option | Meaning |
|---|---|
--port <PORT> | The port to listen on. 0 picks a free one. Default 5000. |
--host <ADDRESS> | The IP address to listen on. Default 127.0.0.1, so only this machine can connect. The admin UI is only served on a loopback address. |
-o, --output <DIR> | The directory to build into and serve. Defaults to public in the project root. It must be as safe to empty as the output of motabhai build. |
motabhai deploy
motabhai deploy [TARGET] [-o DIR]
Builds the site as motabhai build does, hooks included, then deploys the
output to the [deploy.TARGET] table of motabhai.toml. TARGET can be
left out when there is exactly one target; with none or several the
command fails with motabhai::deploy::no_target. A name that is not a
target (motabhai::deploy::unknown_target) and missing S3 credentials
(motabhai::deploy::credentials) are reported before anything is built.
On success it prints deployed to TARGET: and what was published. See
Deploying.
| Option | Meaning |
|---|---|
-o, --output <DIR> | The directory to build into and deploy from. Defaults to public in the project root. |
motabhai clean
motabhai clean [-o DIR]
Removes the output directory and the build state that belongs to it in
.motabhai/, so the next build starts from scratch. The build state of
other output directories is kept. Nothing to clean is not an error, and a
source directory is never removed.
| Option | Meaning |
|---|---|
-o, --output <DIR> | The output directory to remove. Defaults to public in the project root. |
Environment variables
| Variable | Used by |
|---|---|
MOTABHAI_CACHE_DIR | The per-user cache, where downloaded Tailwind executables are kept. By default it is ~/Library/Caches/motabhai on macOS, $XDG_CACHE_HOME/motabhai or ~/.cache/motabhai on Linux, and %LOCALAPPDATA%\motabhai on Windows. |
MOTABHAI_TAILWIND_MIRROR | Where Tailwind executables are downloaded from, in place of Tailwind's GitHub releases. |
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN | Credentials for s3 deploy targets. |
motabhai sets MOTABHAI_ROOT and MOTABHAI_OUTPUT for build hooks.