Templating

barely makes use of the popular jinja2 templating framework.

The below instructions only scratch the surface of jinja's power, so do yourself a favor and read the documentation!

read full documentation

template usage

All your templates live in the templates/ folder inside your devroot. If, for whatever reason, you want to place them somewhere else, set the TEMPLATES_DIR variable in your config.yaml.

You can organize your templates freely inside that folder, including the use of subfolders.

You set a template for a page by naming the page's markdown file according to this scheme:

inheritance

Templates can include or extend other templates:

page variables

Page and theme variables can be included in templates by putting the variable names into double curly braces:

1
{{ variable_name }}

All the variables you specify in global or page-level config are available. In addition, many plugins add their own variables for you to use.

conditions and loops

jinja supports conditional statements:

1
2
3
4
5
{% if condition %}
  {{ something }}
{% else %}
  {{ something_else }}
{% endif %}

as well as loops:

1
2
3
{% for x in list %}
  {{ x }}
{% endfor %}

among others.