Reusable content
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/_reusables/** to keep content architecture predictable for teams.Include syntax
Use the self-closing wc-include tag:
You can also use an absolute docs path:
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:
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
.mdfiles 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:
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.