Skip to content

Instantly share code, notes, and snippets.

@ckunte
Created March 6, 2020 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckunte/1c64d86fc83c58dedc4d29f48fcb7d8c to your computer and use it in GitHub Desktop.
Save ckunte/1c64d86fc83c58dedc4d29f48fcb7d8c to your computer and use it in GitHub Desktop.
Atom feed template in Jinja
{% from 'site_settings.jinja2' import site_title, site_author, site_url -%}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site_title }}</title>
<link rel="alternate" type="text/html" href="{{ site_url }}"/>
<link rel="self" type="application/atom+xml" href="{{ site_url }}/atom.xml"/>
{%- for entry in entries -%}
{%- if loop.index < 1 + 1 %}
<updated>{{ entry.year }}-{{ entry.month }}-{{ entry.day }}T{{ entry.hour }}:{{ entry.minute }}:{{ entry.second }}Z</updated>
{%- endif -%}
{%- endfor %}
<link href="{{ site_url }}/"/>
<author>
<name>{{ site_author }}</name>
</author>
<id>{{ site_url }}/atom.xml</id>
{% for entry in entries %}
<entry>
<title>{{ entry.title | e }}</title>
<link href="{{ site_url }}/{{ entry.url }}"/>
<id>{{ site_url }}/{{ entry.url }}</id>
<updated>{{ entry.year }}-{{ entry.month }}-{{ entry.day }}T{{ entry.hour }}:{{ entry.minute }}:00Z</updated>
<summary>{{ entry.desc | e }}</summary>
</entry>
{%- endfor %}
</feed>
# Site settings
# Site name
{%- set site_title = "yoursite.net" -%}
# Site url (end without /)
{%- set site_url = "https://yoursiteurl.net" -%}
# Author
{%- set site_author = "Your Name" -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment