w5isp.com/templates/rss.xml
Graham McIntire c882c11eed
Filter future-dated posts out of Atom and RSS feeds
Zola's default feed templates include any non-draft page regardless of
its date field, so scheduled posts (date in the future, draft=false)
were showing up in the feed before they were meant to be public.

Override templates/atom.xml and templates/rss.xml with versions that
skip entries whose date is greater than now(). The filter is bypassed
on localhost so zola serve still previews scheduled posts locally,
matching the pattern already used in templates/section.html.
2026-04-22 16:38:22 -05:00

36 lines
1.6 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ config.title }}
{%- if term %} - {{ term.name }}
{%- elif section.title %} - {{ section.title }}
{%- endif -%}
</title>
{% if config.description %}<description>{{ config.description }}</description>{% endif %}
<link>{{ config.base_url | safe }}</link>
<atom:link href="{{ feed_url | safe }}" rel="self" type="application/rss+xml"/>
<generator>Zola</generator>
<lastBuildDate>{{ last_updated | date(format="%a, %d %b %Y %H:%M:%S %z") }}</lastBuildDate>
{%- set is_local = "127.0.0.1" in config.base_url or "localhost" in config.base_url %}
{%- set current_ts = now(timestamp=true) %}
{%- for page in pages %}
{%- set page_ts = page.date | date(format="%s") | int %}
{%- if is_local or page_ts <= current_ts %}
<item>
<title>{{ page.title }}</title>
<pubDate>{{ page.date | date(format="%a, %d %b %Y %H:%M:%S %z") }}</pubDate>
<author>
{%- if page.authors %}{{ page.authors | first }}
{%- elif config.author %}{{ config.author }}
{%- else %}Unknown
{%- endif -%}
</author>
<link>{{ page.permalink | safe }}</link>
<guid>{{ page.permalink | safe }}</guid>
{% if page.summary %}<description>{{ page.summary }}</description>
{% else %}<description>{{ page.content }}</description>{% endif %}
</item>
{%- endif %}
{%- endfor %}
</channel>
</rss>