Commands
Every command and flag, exit codes, what serve does, and creating documents with new.
Run commands as boxlang module:ssg <command> [options] from the site root, or pass --source.
| Command | What it does |
|---|---|
init [dir] | Copies the starter site into dir (default: the current directory). Refuses, with exit code 1, if dir/ssg-config.json already exists. Any other file already in dir is kept: init prints Skipped <file> (already exists) and copies the rest. |
build | Deletes outputDir and builds the whole site into it. With --watch, keeps running and rebuilds whenever the source changes. |
serve | Builds, serves outputDir with a built-in web server, checks the site for changes every second, rebuilds and reloads open pages in the browser. |
list | Prints the documents that would be built, relative to the site root. |
clean | Deletes outputDir. |
new <title> | Creates a Markdown document with its front matter filled in, by default posts/<title-slug>.md. See Creating documents. |
help | Prints usage. Running with no command prints usage too, but exits 1. |
| Flag | Applies to | Meaning |
|---|---|---|
--source <dir> | build, serve, list, clean, new | Site root. Default: the current directory. |
--verbose | build | Lists every file written. |
--drafts | build, serve | Also builds drafts: documents with published: false, and posts (type: post) whose date is in the future. Without it, both are left out of the output and of every collection. Other document types are never skipped because of their date. |
--port <n> | serve | Port to serve on. Default: 8080. |
--watch | build | After building, checks the site for changes every second and rebuilds until you press Ctrl-C. Each rebuild prints its warnings and errors, if any, then a summary line (Rebuilt <n> files in <ms> ms, or Build failed with <n> error(s)); watching continues after a failed rebuild. |
--no-reload | serve | Turns live reload off: pages are served exactly as built. |
--type <type> | new | type written into the front matter: letters, digits, - and _ only (anything else is a usage error). Default: post. |
--dir <dir> | new | Folder for the new file, relative to the site root, outside outputDir. Default: posts for type post, otherwise the site root. |
--draft | new | Adds published: false. |
--watch, --no-reload, --type, --dir and --draft are usage errors (exit code 1) on any other command.
Exit codes:
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | Usage error: unknown command or option, a flag without its value or used with the wrong command, an invalid --port, a source directory that does not exist, init into a folder that already has ssg-config.json, or a new that is refused. |
| 2 | Build failure: invalid configuration, a document that fails to parse or render, a required module that is missing, or a serve port that is already in use. Every failure is printed as <file>: <message>, with the file relative to the site root. |
Problems found before rendering (configuration, front matter, folder defaults, data files, permalink patterns, pagination, two documents writing the same file, a missing passthru entry) stop the build before anything is written or deleted. A page that fails to render is not written; the other pages are, and the build still exits 2.
A render error names the file that actually failed, and the line when BoxLang reports one:
broken.bxm: Function [noSuchFunction] not found (line 3)
_includes/page.bxm: while rendering about.md: The requested key [nope] was not located in any scope or it's undefined (line 1)
When the failing file is a view or layout, the message says which page was being rendered, and the same failure is reported once per build however many pages use that view or layout; none of those pages is written. Compile errors already carry Line: N Col: N in their message and get no extra suffix. When no line can be determined, the suffix is left out.
Notes:
serveuses a small web server built into the module, so it needs nothing beyond BoxLang. It listens on127.0.0.1only, answers a missing page with the site's404.htmlwhen there is one, and tells browsers not to cache. If the port is already in use,servesays so and exits 2. It is a preview server, not something to put on the internet.- Live reload:
serveadds a small inline<script>before</body>(or at the end when there is none) of every HTML page it sends, the 404 page included. The script asks/__ssg/reloadabout once a second and reloads the page after each rebuild, failed rebuilds included, so fixing an error shows up too. The files inoutputDirare never changed; only the response is. With--no-reloadnothing is injected and/__ssg/reloadis an ordinary missing page. serveignoresbaseUrland previews the site at the root: links get no path prefix andabsUrl()andprc.absoluteUrlusehttp://localhost:<port>.builduses the configured value.serveandbuild --watchwatch every file under the site root exceptoutputDir, folders whose name starts with.and symbolically linked folders.outputDiris read again fromssg-config.jsonon every check (the last one that loaded is kept while the file does not load), so changing it triggers one rebuild into the new folder, not a rebuild loop. The old output folder is left in place and from then on counts as source; delete it.servekeeps serving theoutputDirit read at start, even afteroutputDirchanges and the site is rebuilt into the new folder. Stop and restartserveto serve the new one.- The
boxlanglauncher in BoxLang 1.19 splits arguments that contain spaces, so--source "my site"does not work through it.cdinto the site and run the command there instead.
Creating documents
bashboxlang module:ssg new My First Post
boxlang module:ssg new About this site --type page
boxlang module:ssg new Work in progress --draft --dir drafts
The words after new are joined with single spaces to make the title, so quotes are not needed. The file is <dir>/<slugified title>.md under the site root (--source is honoured); its folder is created if needed. It starts with:
markdown---
title: "My First Post"
type: post
date: 2026-11-29
---
date is today, and --draft adds published: false. Runs of whitespace in the title, line breaks included, become single spaces. The title is written as a quoted YAML string, so : and # are safe. new prints the path it created, relative to the site root. It refuses, with exit code 1, when no title is given, when the title produces no usable file name (the slug keeps only a-z, 0-9 and -, so a title such as !!! or one written entirely in a non-Latin script gives an empty name), when the file already exists, or when --dir points outside the site root or into outputDir.