Variables

The following variables are passed to the template. Đ•ach variable corresponds to a data source, which is described in the previous article.

page: dict

Dictonary with article attributes. Data structure example:

page = {
    'title': 'Variables',
    'date': '2022-09-22',
}

Note that the type and template keys are missing. These keys are added implicitly. The page dict will always contain only the data specified directly in the article.

Here type and template fallbacks to defaults:

'template': `template.jinja2`
'type': 'page',

Usage example:

<h1>{{ page.title }}</h1>
site: dict

Dict of values from site section from settings.toml. The structure and data types can be arbitrary.

This data can be used to add custom elements common to the entire site. Below is an example of adding a list of links.

[site]
title = 'My awesome site'
description = 'Awesome site about awesome things'

    [[site.links]]
    title = 'GitHub'
    url = 'https://github.com/username'

    [[site.links]]
    title = 'Twitter'
    url = 'https://twitter.com/username'

This data is serialized into a dictionary with the following structure:

site = {
    'title': 'My awesome site',
    'description': 'Awesome site about awesome things',
    'links': [
        {
            'title': 'GitHub',
            'url': 'https://github.com/username',
        },
        {
            'title': 'Twitter',
            'url': 'https://twitter.com/username',
        }
    ]
}

In template:

{% for link in site.links %}
    <a href="{{ link.url }}">{{ link.title }} </a>
{% endfor %}
aggr: dict

This dictonary contains list of posts and list of pages. The elements of each list consist of dictionaries with strings.

Structure of the aggr dictonary:

aggr = {
    'posts': [
        {
            'title': 'Hello, World!',
            'date': '1970-01-01',
            'type': 'post'
        },
        {
            'title': 'reStructuredText Example',
            'date': '1970-01-01',
            'type': 'post'
        }
    ],
    'pages': [
        {
            'title': 'Variables',
            'date': '2022-09-22'
        }
    ]
}

These lists are applicable, for example, to display a list of posts on the blog's main page.

pygments_theme: str

A string containing the name of the Pygments theme. In settings.toml:

[pygments]
theme = 'rrt'

The default theme is default. An example of usage in a template:

<link rel="stylesheet" href="/css/pygments/{{ pygments_theme }}.css">