Tags
include
Render another template in place.
include renders another template in place. Pass it variables with with.
page.kiln
{% include "partials/header" with { title: page.title } %}
partials/header.kiln
<header>
<a href="/">{{ site.name }}</a>
<span>{{ title }}</span>
</header>
Output
<header>
<a href="/">Example</a>
<span>Pricing</span>
</header>
Isolated by default
An included template only sees the variables you pass with with, plus globals. It can't see the caller's variables. This makes each template's inputs clear, and means it renders the same way wherever you use it.
Use the hash shorthand to pass variables that keep their names: with { page, nav }. Declare what the template expects with props.
Dynamic names
The name can be any expression. This suits content made of sections, where each section type has its own template:
{% for section in page.sections %}
{% include "sections/" ~ section.type with { section } %}
{% endfor %}
Missing templates
Add ignore missing to render nothing when the template doesn't exist:
{% include "sections/" ~ section.type with { section } ignore missing %}