The Stackbit CLI tool can be installed through npm:

npm install -g @stackbit/cli

Once installed, you can use it to validate your stackbit.yaml:

cd <your-project>
stackbit validate

Commands

validate

The validate command runs the following validation steps:

  • Load the stackbit.yaml from the current working directory and validates its structure according to the specification.
  • Load the content files of your site from folders defined by the pagesDir and the dataDir properties.
  • Match the loaded content files to the models defined in stackbit.yaml using the "model matching properties" such as file, folder, match and exclude.
  • Validate the structure of your content files against the models defined in the stackbit.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.

Example

Assume the following site structure:

.
├── content
│   ├── posts
│   │   ├── post1.md
│   │   ├── post2.md
│   │   └── post3.md
│   ├── index.md
│   └── about.md
├── data
│   ├── header.yaml
│   └── footer.json
└── stackbit.yaml

And a stackbit.yaml similar to this:

stackbitVersion: ~0.3.0
ssgName: hugo

dataDir: data
pagesDir: content

...

models:
  home:
    type: page
    label: Home page
    file: index.md
    singleInstance: true
    fields: [...]
  page:
    type: page
    label: Generic page
    exclude:
      - "index.md"
      - "posts/**"
    fields: [...]
  post:
    type: page
    label: Post
    folder: posts
    fields: [...]
  header:
    type: data
    label: Header
    file: header.yaml
    fields: [...]
  footer:
    type: data
    label: Footer
    file: footer.json
    fields: [...]

If everything is configured correctly, running stackbit validate will output this:

loading and validating Stackbit configuration from: /path/to/your/project
  ✔ configuration is valid
loading and validating content from: /path/to/your/project
  loaded 7 files in total (7 matched, 0 unmatched)
  7 files matched to models:
    home: 1 file:
      content/index.md
    page: 1 file:
      content/about.md
    post: 3 files:
      content/posts/post1.md
      content/posts/post2.md
      content/posts/post3.md
    header: 1 file:
      data/header.yaml
    footer: 1 file:
      data/footer.json
  ✔ content files are valid
✔ validation passed

init

Work in progress, coming soon 🚧 🏗

The init command introspects your project files and generates the initial stackbit.yaml for you.