Spelt Docs

Layouts

Spelt uses a customized version of Stencil as its templating language. By setting the layout parameter in the front matter of a post or page, you can determine which template file your content should be rendered into. Template files should be placed in the _layouts folder in your project directory.

Variables

A variable can be defined in your template using the following syntax:

{{ title }}

This will render the title of the current post or page. The content of the variable depends on the current context, which is explained in more detail here.

Tags

Stencil defines several tags that perform special tasks within your template.

Include

You can include other template files in your template using the include tag.

{% include "header.html" %}

Spelt looks for these files inside your project's _includes directory.

For

A for loop allows you to iterate over a collection of items. For instance, your index.html file might contain something similar to this:

{% for post in posts %}
  <h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
{% endfor %}

If

If statements allow you conditionally render part of your template based on whether a variable is truthy (evaluates to true). For example:

{% if title %}
 {{ title }}
{% else %}
 {{ site.title }}
{% endif %}

Similarly you can check for equality using the == operator:

{% if page.title == "About" %}
 // render something specific to About page
{% endif %}

Ifnot

The ifnot tag renders its contents when a variable is falsey (evaluates to false).

{% ifnot post.category %}
 <p>Category undefined</p>
{% endif %}

Gists and math typesetting

In addition to the standard Stencil tags, Spelt supports embedding GitHub gists using the gist tag, and math typesetting using the katex tag.

Filters

Filters allow you to transform the value of a variable in your template. For example:

{{ title | uppercase }}

Spelt supports many different filters, see this page for a complete reference.