Check a site
Check the built pages and the Markdown content of a site with one command, in a terminal or in CI.
contentbit check reads the HTML your build wrote and the Markdown your config
lists, and reports what to fix. It is read-only and never edits files.
Build the site, then run it from the project:
contentbit checkcheck finds the build folder by itself, or reads
site.build. Pass another folder
to check it instead:
contentbit check site/outWhen contentbit.config.ts lists content, check also checks those Markdown
files. A site without Markdown needs no content.
What check looks for lists the checks in plain words.
Set the build folder and the origin
Name the build folder and the public origin in the config when detection does not find them:
import type { ContentbitConfigInput } from 'contentbit'
export default {
content: 'content/**/*.md',
site: {
build: 'apps/web/dist',
origin: 'https://example.com',
},
} satisfies ContentbitConfigInputWithout them, check takes the origin that most canonical URLs use, and the
report says which origin it used. Without any origin, check skips the checks
that need one, such as the sitemap URLs.
Connect Markdown to its built pages
Add page routes so check knows which built page each Markdown document
becomes:
export default {
content: 'content/**/*.md',
links: {
routes: { 'content/blog': '/blog/{slug}/' },
hostRoutes: ['/pricing'],
},
} satisfies ContentbitConfigInputWith routes, a finding that a document causes points at its line, such as the
href of a broken link, and check compares each built page with its document.
Page routes lists what routes add
and how to write them.
Read the report
On a small Astro blog with three posts in content/blog/ and page routes for
them, the report looks like this:
contentbit check
Build dist, 5 pages
Origin https://bakery.example (inferred from canonicals)
Markdown 3 files, 3 with a built page
Built-page findings
error CB_LINK_PAGE_MISSING nav a on 5 pages: / (/about/), /blog/ (/about/), /blog/baking/ (/about/) and 2 more
error CB_LINK_ANCHOR_MISSING 1 finding on 1 page
hint Point the link at an id the page has, or give the element it means that id.
content/blog/proofing.md:15:58 The link /blog/shaping/#pre-shape points to an id that /blog/shaping/ does not have.
warning CB_PAGE_DESCRIPTION_MISSING 1 finding on 1 page
hint Add a <meta name="description"> that sums up the page in a sentence or two.
/blog/ The page has no meta description.
Markdown findings
1. warning integrity CB_HEADING_LEVEL_SKIPPED
at content/blog/baking.md:20:1
heading "Cool the loaf" jumps from h2 to h4
hint Insert an h3 heading or lower this heading level.
Errors 2
Warnings 2Built-page findings come first, grouped by code with errors before warnings.
Each group prints up to five examples, and --json lists every finding.
A finding points at the place to fix it:
- The first line is a template finding. The same
nav aelement links to the missing/about/page on all 5 pages, so the fix belongs in the layout.checkreports it once and counts it as one error. - The second finding comes from a source document. The page routes attach
content/blog/proofing.mdto/blog/proofing/, socheckprints the line and column of the link in the Markdown. - The third finding is on a page with no source document.
/blog/is a listing page that the layout renders, sochecknames the page.
check exits 1 when it reports an error. info findings are suggestions and
never change the exit code.
Each problem is reported once. When a built page and its Markdown file show
the same problem, such as a duplicate title, check reports it on the built
page.
Ignore a finding
Some findings are there on purpose, such as a link to a path that another app serves. Ignore a finding shows how to ignore one, or change the severity of a code, in the config.
When there is no build
- No build folder is found.
checkruns the Markdown checks alone and says so on stderr, with the build command whenpackage.jsonshows Astro, Next.js, or Eleventy. - The folder you name is missing or has no HTML page.
checkexits 2, so a CI job fails when the build writes no static HTML. - Markdown files changed after the build.
checkgives their number and asks you to rebuild. Every built-page error at those files or on their pages becomes a warning, since a rebuild may clear it. Drafts don't count. - No Markdown file has a built page.
checkpoints tocontentbit adopt, which proposes the page routes that attach them.
Watch while editing
contentbit check --watchcheck runs again after a file changes in a scanned content folder or in the
build folder, and reads the registry, the config, and the SEO config again
each time. In CI, run check without it.
Get the report as JSON
contentbit check --json--json prints one report with every finding, its code, and the file and line
or page it points at. check --json lists its
fields.
Next steps
Run check to decide what to fix first, and in CI after the build, as
Run check in CI sets up. Run
context to give an agent a page before it writes.
Run validate on a Markdown file an agent just wrote, before the site builds:
it checks the blocks and the frontmatter links alone. The
CLI reference lists every option and exit code.