Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Both RSS and Atom feeds? #2083

Open
orlp opened this issue Jan 21, 2023 · 3 comments
Open

Both RSS and Atom feeds? #2083

orlp opened this issue Jan 21, 2023 · 3 comments

Comments

@orlp
Copy link
Contributor

orlp commented Jan 21, 2023

Is there a way to support having both an Atom and an RSS feed at the same time?

@Keats
Copy link
Collaborator

Keats commented Jan 22, 2023

Not right now no

@dennisse
Copy link

dennisse commented Jan 23, 2023

You can create a new template to achieve this.

Just create a template for a feed, and use the get_section-function (https://www.getzola.org/documentation/templates/overview/#get-section) to get the root section and use it. Then create a new post/page under content, give it the correct path of your new rss-feed, and set its template to the new template.

Here is an example-template for a new atom-feed, feed.xml:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ lang }}">
    <title>{{ config.title }}
        {%- if term %} - {{ term.name }}
    {%- elif section.title %} - {{ section.title }}
        {%- endif -%}
    </title>
    {%- if config.description %}
    <subtitle>{{ config.description }}</subtitle>
    {%- endif %}
    {%- if not feed_url is defined %}
        {%- set feed_url = page.permalink %}
    {% endif %}
    <link href="{{ feed_url | safe }}" rel="self" type="application/atom+xml"/>
  <link href="
      {%- if section -%}
        {{ section.permalink | escape_xml | safe }}
      {%- else -%}
        {{ config.base_url | escape_xml | safe }}
      {%- endif -%}
    "/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>{{ last_updated | default(value=now()) | date(format="%+") }}</updated>
    <id>{{ feed_url | safe }}</id>
    {%- if not pages is defined %}
        {%- set getpages = get_section(path="_index.md") %}
        {%- set pages = getpages.pages %}
    {%- endif %}
    {%- for p in pages %}
    {%- if not p.relative_path is starting_with("pages/") %}
    <entry xml:lang="{{ p.lang }}">
        <title>{{ p.title }}</title>
        <published>{{ p.date | date(format="%+") }}</published>
        <updated>{{ p.updated | default(value=p.date) | date(format="%+") }}</updated>
        <link rel="alternate" href="{{ p.permalink | safe }}" type="text/html"/>
        <id>{{ p.permalink | safe }}</id>
        <content type="html">{{ p.content }}</content>
    </entry>
    {%- endif %}
    {%- endfor %}
</feed>

And then I create the page content/pages/feed.xml.md with this content:

+++
template = "feed.xml"
path = "feed.xml"
+++

This can be used in addition to whatever feed you've already defined.

@sjehuda
Copy link

sjehuda commented Nov 22, 2023

@dennisse an XSLT stylesheet would be a nice addition too https://gitgud.io/sjehuda/streamburner (you can ignore the CSS file there and add another one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants