More than one custom rss.xml feed

Background

The website I’m creating using zola will need to generate two types of RSS feed.

One which is a regular ATOM feed very much like the template provided by zola and the other is a Podcast audio feed, which supports custom attributes used by iTunes and other podcast platforms.

My approach to the problem

Create a custom RSS.XML in the /templates directory as directed by Zola documentation

The RSS template gets three variables:

Last updated
Pages
Site.Config

I wanted to create a Tera template that did something like this (pseudo code)

{% IF section/taxomony = "PODCAST" THEN %}
..Were using podcast XML
{% ELIF section/taxonomy = "LESSONS" THEN %}
..Were using ATOM XML
{% ENDIF %}

Only I can’t find the section/taxonomy name from the pages (or CAN I ?)

Alternative

I wanted to create a custom RSS.XML in each taxonomy folder

templates\podcasts
list.html
single.html
**rss.xml**

templates\lessons
list.html
single.html
**rss.xml**

Does anyone have another approach? Is it possible to get the section name from pages?

Thanks for any ideas

Ok after spending way to much time on this I discovered an undocumented variable called feed_url which you can see if you use the Tera {{__tera_context}} to display what variables you have available in the context of this template.

So now I have

{% if feed_url is containing("podcast") %}
    {% set podcastRSS = true %}
{% else %}
    {% set podcastRSS = false %}
{% endif %}
{% if podcastRSS %}
    <rss>
    <title>Podcast</title>
    </rss>
{% else %}
< rss>ATOM...></rss>
{% endif %}

So if your stuck like I was take a look at the tera template variable {{__tera_context}}

Maybe we should document the feed_url variable in Zola under the RSS documentation?

Typical I ask a question on a forum and then find the answer almost straight away :slight_smile:

Hopefully this will help others.

Typical I ask a question on a forum and then find the answer almost straight away

As we all do :wink:

I’ll document it in the next version, thanks for reporting that!