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.

CommandWhat 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.
buildDeletes outputDir and builds the whole site into it. With --watch, keeps running and rebuilds whenever the source changes.
serveBuilds, serves outputDir with a built-in web server, checks the site for changes every second, rebuilds and reloads open pages in the browser.
listPrints the documents that would be built, relative to the site root.
cleanDeletes outputDir.
new <title>Creates a Markdown document with its front matter filled in, by default posts/<title-slug>.md. See Creating documents.
helpPrints usage. Running with no command prints usage too, but exits 1.
FlagApplies toMeaning
--source <dir>build, serve, list, clean, newSite root. Default: the current directory.
--verbosebuildLists every file written.
--draftsbuild, serveAlso 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>servePort to serve on. Default: 8080.
--watchbuildAfter 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-reloadserveTurns live reload off: pages are served exactly as built.
--type <type>newtype written into the front matter: letters, digits, - and _ only (anything else is a usage error). Default: post.
--dir <dir>newFolder for the new file, relative to the site root, outside outputDir. Default: posts for type post, otherwise the site root.
--draftnewAdds published: false.

--watch, --no-reload, --type, --dir and --draft are usage errors (exit code 1) on any other command.

Exit codes:

CodeMeaning
0Success.
1Usage 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.
2Build 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:

  • serve uses a small web server built into the module, so it needs nothing beyond BoxLang. It listens on 127.0.0.1 only, answers a missing page with the site's 404.html when there is one, and tells browsers not to cache. If the port is already in use, serve says so and exits 2. It is a preview server, not something to put on the internet.
  • Live reload: serve adds 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/reload about once a second and reloads the page after each rebuild, failed rebuilds included, so fixing an error shows up too. The files in outputDir are never changed; only the response is. With --no-reload nothing is injected and /__ssg/reload is an ordinary missing page.
  • serve ignores baseUrl and previews the site at the root: links get no path prefix and absUrl() and prc.absoluteUrl use http://localhost:<port>. build uses the configured value.
  • serve and build --watch watch every file under the site root except outputDir, folders whose name starts with . and symbolically linked folders. outputDir is read again from ssg-config.json on 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.
  • serve keeps serving the outputDir it read at start, even after outputDir changes and the site is rebuilt into the new folder. Stop and restart serve to serve the new one.
  • The boxlang launcher in BoxLang 1.19 splits arguments that contain spaces, so --source "my site" does not work through it. cd into 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.