Setup
Installation
It is recommended that you install Stackbit locally on your machine.
1
This adds the stackbit
command to your path. See below for usage instructions.
Usage
To see a list of available commands use the --help
flag:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
See below for a list of commands.
Direct Usage with npx
Rather that installing globally, you can also use the CLI directly with npx
:
1
Commands
dev
Boot Stackbit dev, our local development server, used for developing projects locally before importing into production with Stackbit. Learn more about local development.
1
2
init
[experimental]
This command has not been updated for full support of Stackbit v2. Use is experimental and may be removed in a future version.
You can also create a new project using create-stackbit-app, or follow the tutorial to add Stackbit to your site.
The init
command introspects your project files and generates the initial stackbit.yaml
for you. To generate a new stackbit.yaml
file, run the init
command inside your project's root folder:
1
2
Stackbit CLI will generate the initial stackbit.yaml
according to your project files. If your project doesn't use any CMS, the init
command will also generate the content model. The content model generation relies on your project's content files (e.g., .md
, .json
, .yaml
).
Note that the generated stackbit.yaml
is the "best guess", so it might not have the best content model for your site. For example, fields that could store markdown content might be marked as strings. After generating the stackbit.yaml
file, we recommend reviewing it and adjusting it if needed. We also recommend running the validate
command to check if there are content files without matched models.
validate
[experimental]
The validate
command is used to validate Stackbit configuration. It runs the following validation steps:
- It loads the
stackbit.yaml
from the current working directory and validates its structure according to the specification. - It loads your site's content files from folders defined by the
pagesDir
and thedataDir
properties. - It matches the loaded content files to the
models
defined instackbit.yaml
using the "model matching properties" such asfile
,folder
,match
andexclude
. - It validates the structure of your content files against the
models
defined in thestackbit.yaml
.
If the validator finds any errors during these validation steps, it will print them to your console providing contextual information allowing you to fix them.
analyze-repo
[experimental]
telemetry-enable
& telemetry-disable
Stackbit contains a telemetry feature that collects anonymous information on the usage of Stackbit CLI commands. We do this to improve the reliability of Stackbit CLI and help drive new features and improvements. Learn more about data collected via telemetry.
If you'd like to opt-out of sending usage information, you can do so by running the following command:
1
2
3
4
5