Reusing content

Doctave supports a subset of the Liquid Templating language which allows you to reuse content across your project with partial templates.

Including partial templates in a page

Partial templates live under the _partials directory, which should be located in the project root.

Partials should have a .md extension, just like other Markdown files.

<!-- Content of `_partials/example.md` -->

Tomato, pineapple, orange and pear.

To include this partial in your page, you use the following syntax:

These are my favorite fruits

{% include "_partials/example.md" %}

You should now see the content show up:

These are my favorite fruits

Tomato, pineapple, orange and pear.

Adding variables to partial templates

You can add variables to your partials to create more reusable content.

# Content of `_partials/example-with-variable.md`

Hello, {{ name }}!

To include this partial and add a name, you can use the following syntax:

Oh, it's Eve.

{% include "_partials/example-with-variable.md" name: "Eve" %}

This will produce:

Oh, it's Eve.

Hello, Eve!

Was this page helpful?