Reusable content

Writing•5 min read|
|

DocsLit supports reusable markdown fragments through compile-time includes. This keeps repeated setup steps and shared notices in one source of truth.

Opinionated structure

Reusable files must live under docs/_reusables/.

docs/ getting-started/ quickstart.md _reusables/ shared/ install-cli.md notices/ support-policy.md Includes are intentionally limited to docs/_reusables/** to keep content architecture predictable for teams.

Include syntax

Use the self-closing wc-include tag:

<wc-include src="shared/install-cli.md" />

You can also use an absolute docs path:

<wc-include src="/docs/_reusables/shared/install-cli.md" />

Pass props to a snippet

Any attribute on wc-include other than src is a prop. It fills the matching {{name}} placeholder inside the snippet, so one snippet can serve several pages:

Water your {{plant}} every {{interval}}. <wc-include src="water.md" plant="fern" interval="week" />

This renders as "Water your fern every week." Props are lowercase-friendly, so you do not need UPPER_SNAKE_CASE names inside reusable files. Page and global variables still work inside snippets.

Include rules

  • only .md files can be included
  • include targets must be under docs/_reusables/**
  • include tags must be self-closing
  • reusable files cannot include other files (no nested includes)

Validation

Run validation before building:

docslit validate

Validation reports invalid include paths, nested include usage in reusable files, and undefined variables.

See Variables and precedence for variable behavior and built-in version variables.