Data

Globals

containers

A dictionary of the defined content containers.

containers[container]

A container object.

Iterating over this object yields it's items.

container.archives

A dictionary of the container's archive data.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{% for archive in container.archives|values %}
    <h1>{{ archive.year }}</h1>
    <ul>
        {% for month, items in archive.months|items %}
            <li>
                <h1>{{ month }}</h1>
                <ul>
                    {% for item in items %}
                        <li>{{ item.timestamp|date('%d') }}<a href="{{ get_url(item.url) }}">{{ item.title }}</a></li>
                    {% endfor %}
                </ul>
            </li>
        {% endfor %}
    </ul>
{% endfor %}
container.items
A list of the container's items.
container.tags

A dictionary of the container's tags.

1
2
3
{% for tag in container.tags|values %}
    <li><a href="{{ get_url(tag.url) }}">{{ tag.name }} ({{ tag.count }})</a></li>
{% endfor %}
posts
A container object of the site's posts.
site
A dictionary of the site's configuration data.

Locals

archive

A dictionary of archive data.

This variable is only available in archive_layout templates.

archive.months
A dictionary of items sorted by month in reverse chronological order.
archive.url
The URL to the year's archive page based on the archives_url configuration setting.
archive.year
The year of the archive.
item

A dictionary of item data.

This variable is only available in layout templates.

item.content
The body of the item.
item.date
The date of the item formatted according to the date_format configuration setting.
item.excerpt

The contents of the first <p> of content.

Only available for container items.

item.prev
The previous item in the container.
item.next
The next item in the container.
item.tags

A list of the names of the item's tags.

Only available for container items.

If you want to get the data for a specific tag, you can get it from the container's tags:

1
2
3
4
5
6
7
8
9
{% for tag in item.tags %}
    {#
        for posts: posts.tags
        for containers: containers.<container name>.tags
    #}
    {% set data = posts.tags[tag] %}

    <a href="{{ get_url(data.url) }}">{{ tag }} <em>({{ data.count }})</em></a>{% if not loop.last %}, {% endif %}
{% endfor %}
item.timestamp
The timestamp of the item.
item.url
The URL of the item formatted according to the appropriate URL format.
tag

A tag object.

This variable is only available in tag_layout templates.

Iterating over this object yields it's items.

tag.archives
An archive containing only items belonging to the tag.
tag.count
The number of tagged items.
tag.items
A list of the tag's items.
tag.name
The name of the tag.
tag.url
The URL to the tag page based on the tags_url configuration setting.

Filters

absolutize(html)

Attempts to convert all URLs in the supplied HTML to absolute URLs.

This filter depends on the domain configuration setting.

html
The chunk of HTML to convert.
date(ts, format)

Returns a formatted date based on the supplied timestamp and format.

1
{{ item.timestamp|date('%d %b %Y') }}
ts

The timestamp to be formatted.

If None, the current date and time will be used.

format
The desired format of ts.
items(dict)
Alias for dict.items().
values(dict)
Alias for dict.values().

Helpers

get_asset(asset)

Returns the URL to the asset based on the base_url and assets_url configuration settings.

1
<link rel="stylesheet" href="{{ get_asset('css/screen.css') }}">
asset
The requested asset.
get_url(url, absolute)

Returns a URL based on the base_url configuration setting.

1
<a href="{{ get_url(item.url) }}">{{ item.title }}</a>
url

The requested URL.

This parameter is optional. If not supplied, the base_url configuration setting will be returned.

absolute

Whether or not the returned URL should be an absolute URL.

This depends on the domain configuration setting.

Fork me on Github