8.6 Command-Line Interface
Camp provides several commands through Racket’s raco tool. All commands operate on the site in the current directory (or the directory containing the current package).
8.6.1 raco camp build
Builds the site by running the collect and build passes. Source documents are processed, rendered through their collection’s render function, and written to the output folder (default: "publish").
# build ./site.rkt |
raco camp build |
|
# build using named file |
raco camp build path/to/site.rkt |
|
# build installed package "myblog" |
raco camp build myblog |
The --fresh flag clears the output folder before building. Without this flag, existing files are overwritten but stale files from previous builds may remain.
The --verbose flag enables detailed output, including timing for the site loading phase and information about individual file operations.
The --drama flag treats warnings as errors, causing the build to fail if any warnings are logged. This is useful in continuous integration environments where you want strict validation.
Build output shows timing for each phase (Collect, Build, Feeds, Static) and summarizes any warnings at the end. A typical build looks like:
Collect 42 pages 23ms |
Build 42 pages 156ms |
Feeds 1 feed 8ms |
Static 12 files 14ms |
──────────────────────────────────────────────── |
Total 201ms |
8.6.2 raco camp serve
Starts a development server and optionally watches for file changes. By default, the server listens on port 8000 and automatically rebuilds when source files change.
The [site] argument can be a path to "site.rkt" or the name of an installed package. If omitted, looks for "site.rkt" in the current directory.
The --port flag specifies an alternative port number.
The --no-watch flag disables file watching, running only the static server without automatic rebuilds.
When watching is enabled, Camp monitors source documents, render modules, static files, and the site configuration. Changes trigger appropriate actions: source document or render module changes trigger a full rebuild, static file changes sync to the output folder, and configuration changes reload the site and rebuild.
The server provides directory listings for folders without an "index.html" and returns a styled 404 page for missing files.
8.6.3 raco camp deploy
Runs the deployment script specified in your site configuration. The script receives the output folder path as its first argument.
The [site] argument can be a path to "site.rkt" or the name of an installed package. If omitted, looks for "site.rkt" in the current directory.
If no deploy-script is configured in "site.rkt", this command reports an error.
A typical deployment script might rsync files to a server, push to a Git repository, or upload to a hosting service:
"deploy.sh"
#!/bin/bash
rsync -avz --delete "$1/" user@server:/var/www/mysite/
Configure it in your site:
deploy-script = "./deploy.sh"
8.6.4 raco camp new
Creates a new site from the built-in template. The <name> argument specifies the directory to create.
The generated site includes a minimal but functional structure: package metadata, site configuration, a sample post, render functions, and basic CSS. It’s designed as a starting point for customization rather than a production-ready theme.
After creating a site, install it as a local package and build:
cd <name> |
raco pkg install |
raco camp serve |