|
| 1 | +--- |
| 2 | +title: CLI reference |
| 3 | +description: 'An up-to-date list of available metalsmith commands: build, init, clean' |
| 4 | +draft: false |
| 5 | +toc: true |
| 6 | +layout: default.njk |
| 7 | +order: 6 |
| 8 | +sitemap: |
| 9 | + priority: 0.7 |
| 10 | + lastmod: 2026-02-09 |
| 11 | +config: |
| 12 | + anchors: true |
| 13 | +--- |
| 14 | + |
| 15 | + |
| 16 | +## Metalsmith |
| 17 | + |
| 18 | +{% codeblock "metalsmith --help" %} |
| 19 | +```plaintext |
| 20 | +Usage: metalsmith [options] [command] |
| 21 | +
|
| 22 | +Metalsmith CLI |
| 23 | +
|
| 24 | +Options: |
| 25 | + -V, --version output the version number |
| 26 | + -h, --help display help for command |
| 27 | +
|
| 28 | +Commands: |
| 29 | + build [options] Run a metalsmith build |
| 30 | + init [options] [source] [destination] Initialize a new metalsmith project from a git repo (subpath). Runs a sequence of git and filesystem commands. |
| 31 | + Assumes a working git executable in $PATH and properly configured git/ssh configs. |
| 32 | + clean [options] [destination] Clean a directory |
| 33 | + help [command] display help for command |
| 34 | +
|
| 35 | + Examples: |
| 36 | +
|
| 37 | + # build from metalsmith.json: |
| 38 | + metalsmith |
| 39 | +
|
| 40 | + # build from lib/config.json: |
| 41 | + metalsmith --config lib/config.json |
| 42 | +
|
| 43 | + # override env vars |
| 44 | + metalsmith --env NODE_ENV=production TZ=Europe/London |
| 45 | +
|
| 46 | + # override DEBUG env var (shortcut) |
| 47 | + metalsmith --debug @metalsmith/* |
| 48 | + |
| 49 | +``` |
| 50 | +{% endcodeblock %} |
| 51 | + |
| 52 | +### metalsmith build |
| 53 | + |
| 54 | +{% codeblock "metalsmith build --help" %} |
| 55 | +```plaintext |
| 56 | +Usage: metalsmith build [options] |
| 57 | +
|
| 58 | +Run a metalsmith build |
| 59 | +
|
| 60 | +Options: |
| 61 | + -c, --config <path> configuration file location (default: "metalsmith.json") |
| 62 | + --env <setting...> Set or override one or more metalsmith environment variables. |
| 63 | + --debug Set or override debug namespaces |
| 64 | + --dry-run Process metalsmith files without outputting to the file system |
| 65 | + -h, --help display help for command |
| 66 | +``` |
| 67 | +{% endcodeblock %} |
| 68 | + |
| 69 | +### metalsmith init |
| 70 | + |
| 71 | +{% codeblock "metalsmith init --help" %} |
| 72 | +```plaintext |
| 73 | +Usage: metalsmith init [options] [source] [destination] |
| 74 | +
|
| 75 | +Initialize a new metalsmith project from a git repo (subpath). Runs a sequence of git and filesystem commands. |
| 76 | +Assumes a working git executable in $PATH and properly configured git/ssh configs. |
| 77 | +
|
| 78 | +Arguments: |
| 79 | + source Source directory (default: "starters/bare") |
| 80 | + destination Destination directory, defaults to current directory (default: ".") |
| 81 | +
|
| 82 | +Options: |
| 83 | + -f, --force Force overwriting a non-empty directory (default: false) |
| 84 | + -o, --origin <origin> Origin repository (https or ssh url, or a directory path). Defaults to https://github.com/metalsmith/resources if omitted (default: |
| 85 | + "https://github.com/metalsmith/resources") |
| 86 | + -h, --help display help for command |
| 87 | +``` |
| 88 | +{% endcodeblock %} |
| 89 | + |
| 90 | +### metalsmith clean |
| 91 | + |
| 92 | +{% codeblock "metalsmith clean --help" %} |
| 93 | +```plaintext |
| 94 | +Usage: metalsmith clean [options] [destination] |
| 95 | +
|
| 96 | +Clean a directory |
| 97 | +
|
| 98 | +Arguments: |
| 99 | + destination Destination directory, defaults to metalsmith.destination() |
| 100 | +
|
| 101 | +Options: |
| 102 | + -c, --config [path] configuration file location (default: "metalsmith.json") |
| 103 | + -h, --help display help for command |
| 104 | +``` |
| 105 | +{% endcodeblock %} |
0 commit comments