GuideHow-to recipes
Add an RSS feed
Publish an RSS 2.0 feed of a collection with a feed.xml.liquid template, and optionally the full HTML of each post.
A feed is a template: feed.xml.liquid in the content folder is rendered like a page and written to feed.xml. It
lists the pages of a collection, newest first. Feeds are not in the collections themselves, and layouts only apply to
HTML files, so the template writes the whole document.
Tag the postsLink to this heading
Give every post a tag, here post, and a date. A data file in the posts folder sets the tag and the layout for
every page in it:
layout: post.liquid
tags: post
---
title: First post
date: 2026-01-10T09:00:00Z
description: What this blog is about.
---
Hello **world**.
Set the site URLLink to this heading
Feed readers need absolute links. Set site.url in douze.yml; the absolute_url filter prefixes it:
site:
url: https://example.com
The title and description of the feed can come from a data file, _data/site.json, which is merged with the site
section:
{ "title": "My blog", "description": "Notes about things" }
Write the feedLink to this heading
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ site.title }}</title>
<link>{{ '/' | absolute_url }}</link>
<description>{{ site.description }}</description>
<atom:link href="{{ '/feed.xml' | absolute_url }}" rel="self" type="application/rss+xml"/>
{%- assign posts = collections.post | reverse %}
{%- if posts.size > 0 %}
<lastBuildDate>{{ posts.first.data.date | date_to_rfc822 }}</lastBuildDate>
{%- endif %}
{%- for post in posts limit: 20 %}
<item>
<title>{{ post.data.title }}</title>
<link>{{ post.data.url | replace: 'index.html', '' | absolute_url }}</link>
<guid>{{ post.data.url | replace: 'index.html', '' | absolute_url }}</guid>
<pubDate>{{ post.data.date | date_to_rfc822 }}</pubDate>
{%- if post.data.description %}
<description>{{ post.data.description }}</description>
{%- endif %}
</item>
{%- endfor %}
</channel>
</rss>
The build writes _site/feed.xml:
<item>
<title>First post</title>
<link>https://example.com/blog/first/</link>
<guid>https://example.com/blog/first/</guid>
<pubDate>Sat, 10 Jan 2026 09:00:00 +0000</pubDate>
<description>What this blog is about.</description>
</item>
Notes on the template:
- Collections are sorted by date ascending, so
reverseputs the newest post first. urlis the output path (/blog/first/index.html):replace: 'index.html', ''turns it into the folder URL.- The
liquidstep encodes the outputs of an XML file for XML:{{ post.data.title }}writesSecond <post>, and the dates keep their+0000.xml_escapeis not needed, and not encoded again where it is used.
Point to the feed from the layout of the pages:
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ '/feed.xml' | absolute_url }}">
Include the full contentLink to this heading
The items of collections.post have the data of each post, not its HTML: the default collections step runs before
Liquid and Markdown. To put the rendered posts in the feed, add a second collect step after markdown with
content: true, and render the feed after it. This replaces the default workflow, so douze.yml lists every step:
site:
url: https://example.com
steps:
site-data:
inputs: "_data/**/*.{yml,yaml,json,xml}"
uses: data
with:
scope: site
folder-data:
inputs: "_content/**/*.{yml,yaml,json,xml}"
uses: data
with:
scope: folder
root: _content
pages:
inputs: ["_content/**", "!_content/**/*.{yml,yaml,json,xml}"]
needs: [site-data, folder-data]
uses: frontmatter
permalink:
needs: pages
uses: permalink
with:
root: _content
collections:
needs: permalink
uses: collect
paginate:
needs: [permalink, collections]
uses: paginate
render:
needs: paginate
uses: liquid
match: ["**/*.{html,md,json,xml,txt}", "!feed.xml"]
markdown:
needs: render
uses: markdown
# The posts after Markdown, with their HTML, as feed.all and feed.<tag>
feed-posts:
needs: markdown
uses: collect
match: "blog/**/*.html"
with:
name: feed
content: true
feed:
needs: [markdown, feed-posts]
uses: liquid
match: feed.xml
layout:
needs: feed
uses: layout
write:
needs: layout
uses: write
Steps after permalink see output paths: the feed is feed.xml, and the posts are blog/first/index.md before the
markdown step and blog/first/index.html after it. render leaves the feed alone, and feed renders it once
feed-posts has collected every post. In the template, read feed.post instead of collections.post, and write
content, which the encoder escapes as RSS expects:
{%- assign posts = feed.post | reverse %}
{%- for post in posts limit: 20 %}
<item>
<title>{{ post.data.title }}</title>
<link>{{ post.data.url | replace: 'index.html', '' | absolute_url }}</link>
<pubDate>{{ post.data.date | date_to_rfc822 }}</pubDate>
<description>{{ post.content }}</description>
</item>
{%- endfor %}
content is the HTML of the post before its layout. With content: true, the collect step holds every post's HTML in
memory and runs again when any post changes.