From c882c11eeda86cf57b6b1c8e0de31e5854d0626c Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 22 Apr 2026 16:38:22 -0500 Subject: [PATCH] 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. --- templates/atom.xml | 43 +++++++++++++++++++++++++++++++++++++++++++ templates/rss.xml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 templates/atom.xml create mode 100644 templates/rss.xml diff --git a/templates/atom.xml b/templates/atom.xml new file mode 100644 index 0000000..110c4c4 --- /dev/null +++ b/templates/atom.xml @@ -0,0 +1,43 @@ + + + {{ config.title }} + {%- if term %} - {{ term.name }} + {%- elif section.title %} - {{ section.title }} + {%- endif -%} + + {% if config.description %}{{ config.description }}{% endif %} + + + Zola + {{ last_updated | date(format="%+") }} + {{ feed_url | safe }} + {%- 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 %} + + {{ page.title }} + {{ page.date | date(format="%+") }} + {{ page.updated | default(value=page.date) | date(format="%+") }} + + + {%- if page.authors %} + {{ page.authors | first }} + {%- elif config.author %} + {{ config.author }} + {%- else %} + Unknown + {%- endif %} + + + + {{ page.permalink | safe }} + {% if page.summary %} + {{ page.summary }} + {% endif %} + {{ page.content }} + + {%- endif %} + {%- endfor %} + diff --git a/templates/rss.xml b/templates/rss.xml new file mode 100644 index 0000000..ead20af --- /dev/null +++ b/templates/rss.xml @@ -0,0 +1,36 @@ + + + + {{ config.title }} + {%- if term %} - {{ term.name }} + {%- elif section.title %} - {{ section.title }} + {%- endif -%} + + {% if config.description %}{{ config.description }}{% endif %} + {{ config.base_url | safe }} + + Zola + {{ last_updated | date(format="%a, %d %b %Y %H:%M:%S %z") }} + {%- 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 %} + + {{ page.title }} + {{ page.date | date(format="%a, %d %b %Y %H:%M:%S %z") }} + + {%- if page.authors %}{{ page.authors | first }} + {%- elif config.author %}{{ config.author }} + {%- else %}Unknown + {%- endif -%} + + {{ page.permalink | safe }} + {{ page.permalink | safe }} + {% if page.summary %}{{ page.summary }} + {% else %}{{ page.content }}{% endif %} + + {%- endif %} + {%- endfor %} + +