Include
{% include %} pastes a shared file's content into the page, like {% partial %} — but early enough that {% data %} and {% snippet %} inside that file resolve.
{% include file="attribute-table.md" variables={rune: "card"} /%}
Both runes read the same _partials/ directory and the same file roots, so moving between them changes the call site and nothing else. A file's location does not depend on its contents.
When to use which
Reach for {% partial %} first. It is Markdoc's own tag, it works the same way in every Markdoc project, and it covers the common case: a reusable chunk of content, with or without variables.
Reach for {% include %} when the file contains {% data %} or {% snippet %}. Those are refrakt's, and they resolve in a phase Markdoc does not know about — see below. include is otherwise a strict superset, so switching costs nothing but the tag name.
partial | include | |
|---|---|---|
| Whose tag | Markdoc's | refrakt's |
Reads _partials/ and file roots | yes | yes |
Takes variables | yes | yes |
Contains data / snippet | no — the build stops | yes |
| Sees the page's own variables | no — its scope replaces them | yes, for anything it does not bind |
The problem it solves
Markdoc expands {% partial %} during the transform phase. refrakt resolves data and snippet in a preprocess phase that runs before that, walking the page's syntax tree — and a partial's content is not in that tree yet when it runs. So the tag survives, reaches its own transform, and the build stops:
{% data %} reached the transform phase unresolved.
If this file is pulled in with {% partial %}: use {% include %} instead.
include runs first in the preprocess phase and splices the file's content into the page, so everything that follows sees it as ordinary page content.
Setup
There is no separate setup. Put the file in _partials/ exactly as you would for a partial, and reference it by the same key.
content/
├── _partials/
│ ├── cta.md ← plain content: use {% partial %}
│ └── attribute-table.md ← contains {% data %}: use {% include %}
└── runes/
└── card.md
{% include file="attribute-table.md" /%}
{% include file="shared/attribute-table.md" /%}
{% include file="shared:attribute-table.md" /%}
Passing variables
variables works the way it does on partial — a map of bindings the file reads with $.
Included file (_partials/attribute-table.md):
{% data src="_data/rune-attributes.json" root="attributes" where=$q %}
### {% $row.name %}
{% $row.description %}
{% /data %}
Usage:
{% include file="attribute-table.md" variables={q: "rune:card scope:own"} /%}
The difference from partial is where the binding lands. A partial's variables are a scope the transform reads, which is exactly the phase a preprocessor rune never reaches. An include substitutes them into the content as it pastes, so a binding reaches {% data where=$q %} — the case above.
One consequence worth knowing: variables the include does not bind are left alone rather than blanked, so {% $page.slug %} inside an included file still resolves against the page. A partial cannot do that — its scope replaces the variable surface.
Nesting
An included file can include another. Depth is bounded, and a cycle is reported by name rather than overflowing the stack:
include error: cycle — a.md → b.md → c.md → a.md
Content boundaries
The pasted content lands as siblings at the call site, not wrapped in a container. That is what lets a parent rune read it:
{% accordion %}
{% include file="faq-items.md" /%}
{% /accordion %}
The accordion sees the included headings as its own children and builds one item per heading. Had the content been wrapped, {% section %} and {% grid %} would consume it and the items would vanish with no error — so it is not.
Attributes
| Attribute | Type | Required | Description |
|---|---|---|---|
file | string | ✓ | Partial to paste, by the same key `{% partial %}` uses — a path under the site's `_partials/` (e.g. "attrs.md") or a namespaced file root ("shared:attrs.md"). |
variables | Object | — | Bindings substituted into the pasted AST at paste time, e.g. variables={q: "rune:card"} makes `$q` inside the file that string. Unlike `partial`, this is substitution rather than a transform-time scope, so bound values reach preprocessor attributes such as `{% data where=$q %}`. |
Universal attributes
bg
The background layer (SPEC-088): image, video, gradient, flat overlay wash and legibility scrim, in a single injected layer behind the rune's content.
| Attribute | Type | Required | Description |
|---|---|---|---|
bg | string | — | Background preset applied to this block |
bg-from | string | — | Gradient start colour — a semantic token name (→ var(--rf-color-*)) |
bg-gradient | "to-t" | "to-b" | "to-l" | "to-r" | "to-tr" | "to-br" | "to-bl" | "to-tl" | — | Gradient direction (bounded named set) |
bg-gradient-type | "linear" | "radial" | "conic" | — | Gradient type |
bg-to | string | — | Gradient end colour — a semantic token name |
bg-via | string | — | Optional middle gradient stop — a semantic token name |
scrim | "top" | "bottom" | "left" | "right" | "none" | — | Scrim direction (heaviest edge); presence turns the scrim on, "none" opts out of the default cover scrim |
scrim-blur | "none" | "sm" | "md" | "lg" | — | Frost scrim blur amount |
scrim-strength | "sm" | "md" | "lg" | — | Gradient scrim strength |
scrim-tone | "dark" | "light" | — | Whether the scrim darkens (for light text) or lightens (for dark text) |
scrim-type | "gradient" | "frost" | — | Scrim treatment: gradient (default) or frost (backdrop blur) |
elevation
The chrome/depth ladder (SPEC-107). The skin maps each rung to a chrome bundle by attribute, so there is no BEM class.
| Attribute | Type | Required | Description |
|---|---|---|---|
elevation | "sunken" | "flush" | "flat" | "raised" | "floating" | "overlay" | "none" | "sm" | "md" | "lg" | — | Surface depth on the SPEC-107 ladder (sunken→overlay); none/sm/md/lg are deprecated aliases |
inset
Internal padding override.
| Attribute | Type | Required | Description |
|---|---|---|---|
inset | "flush" | "tight" | "default" | "loose" | "breathe" | — | Inner padding of this block |
motion
Scroll-reveal entrance (SPEC-105). The author declares the character, the theme owns the choreography, a behaviour owns the timing.
| Attribute | Type | Required | Description |
|---|---|---|---|
reveal | "none" | "fade" | "slide" | "scale" | "blur" | — | Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography |
stagger | boolean | — | Cascade this block's items in as it reveals (no-op on single-child runes) |
spacing
Block-level rhythm override.
| Attribute | Type | Required | Description |
|---|---|---|---|
spacing | "flush" | "tight" | "default" | "loose" | "breathe" | — | Vertical spacing above and below this block |
substrate
Generated pattern fills (SPEC-087). Markers only — the engine sets the attributes and cell/opacity custom properties, CSS draws the pattern.
| Attribute | Type | Required | Description |
|---|---|---|---|
substrate | "dots" | "grid" | "lines" | "cross" | "checker" | "none" | — | Generated surface pattern |
substrate-fill | "inherit" | "inset" | — | Surface fill the pattern sits on (full colour stays with tint) |
substrate-opacity | "sm" | "md" | "lg" | — | Pattern ink strength |
substrate-size | "sm" | "md" | "lg" | — | Pattern cell size |
substrate-target | "self" | "media" | — | Which surface the pattern fills (overrides the rune/theme default) |
tint
Per-rune colour override (SPEC-053): a named tint from the theme registry, with inline per-token overrides layered on top.
| Attribute | Type | Required | Description |
|---|---|---|---|
tint | string | — | Color tint preset applied to this block |
tint-mode | "auto" | "dark" | "light" | — | Whether the tint adapts to auto, dark, or light mode |
width
The track a block rune occupies.
| Attribute | Type | Required | Description |
|---|---|---|---|
width | "compact" | "narrow" | "content" | "wide" | "full" | — | Maximum width constraint for this block |
| Not available | Why |
|---|---|
| dropcap, reading | this rune declares no prose body |
| frame | this rune declares neither a `frameTarget` nor a media section |
| prominence | this rune has no page-section header |
Errors
Failures render on the page as a caution callout and record a build error; one bad include does not take down the build.
| Message | Cause |
|---|---|
"x.md" was not found in _partials/ or any registered file root | No such key. The message lists what is available. |
the \file` attribute is required` | Omitted, or a variable reference that resolved to empty. |
cycle — a.md → b.md → a.md | A file includes itself, directly or through a chain. |
nested more than 16 deep | A chain of distinct files past the depth bound. |