This documents lists useful patterns.

Creating an index page

The easiest way to create an index page is to create an index.html file in the input directory and loop over the articles variable:

Create the file:

touch input/index.html

The content might look like this:

status: hidden
template: self

{% extends "base.html" %}

{% block content %}
    {% for article in articles %}
        <li><a href="{{ article.url }}">{{ article.title }}</a></li>
    {% endfor %}
{% endblock %}

Setting the status to hidden prevents that the index page itself will show up in the articles variable.

Creating an Atom feed

Creating a feed is similar to creating an index page. Create an atom.xml file:

touch input/atom.xml

And make sure you set status: hidden, so the feed itself doesn’t show up in the articles variable:

status: hidden
template: self

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="">
    <title>My Website</title>
    <link href="" rel="self" />
    <link href="" />
    <updated>{{ articles[-1]|datetimeformat("%Y-%m-%dT%H:%M:%SZ") }}</updated>
        <name>Foo Bar</name>

    {% for article in articles %}
        <title>{{ article.headers.title }}</title>
        <link href="{{ article.headers.url }}" />
        <updated>{{|datetimeformat("%Y-%m-%dT%H:%M:%SZ") }}</updated>
        <id>{{ article.headers.url }}</id>
        <content type="html">{{ article.body|e }}</content>
 {% endfor %}

Project Versions

Table Of Contents

Previous topic


This Page