<p>It turns out that you can call the template file directly and it answers by default with the right response headers.</p>

<p>So for example, putting templates named <code>feed.atom</code> and <code>feed.rss</code> in the root of your template folder enables you to call them via <code>/feed.atom</code> and <code>/feed.rss</code>.
No need for setting content-type by hand.</p>

CC BY-SA 3.0
2015-10-21T06:33:15.177Z
2015-10-21T06:33:15.177Z
Roel
<p>Yeah, so I have a <code>rss.twig</code> file in the root of my template directory.</p>

<pre><code>{% header "Content-Type: application/rss+xml" %}
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"&gt;

{% set rss = craft.entries.section('article').limit(10).type('article') %}

&lt;channel&gt;
  &lt;title&gt;My Site Name&lt;/title&gt;
  &lt;link&gt;{{ siteUrl }}&lt;/link&gt;
  &lt;description&gt;My site description&lt;/description&gt;
  &lt;language&gt;en-au&lt;/language&gt;
  &lt;atom:link href="{{ url() }}" rel="self" type="application/rss+xml" /&gt;

  {% for item in rss %}
  &lt;item&gt;
    &lt;title&gt;&lt;![CDATA[{{ item.title|raw }}]]&gt;&lt;/title&gt;
    &lt;link&gt;{{ item.url() }}&lt;/link&gt;
    &lt;description&gt;&lt;![CDATA[
    {% for block in item.body %}

  {% if block.type == "text" %}

    {{ block.text }}

  {% elseif block.type == "footnote" %}

    {% include 'blocks/_footnote' %}

  {% elseif block.type == "pullQuote" %}

    {% include 'blocks/_pullquote' %}

  {% elseif block.type == "heading" %}

    {% include 'blocks/_heading' %}

  {% elseif block.type == "image" %}

    {% include 'blocks/_image' %}

  {% elseif block.type == "audio" %}

    {% include 'blocks/_audio' %}

  {% elseif block.type == "video" %}

    {% include 'blocks/_video' %}

  {% endif %}

{% endfor %}]]&gt;&lt;/description&gt;
    &lt;pubDate&gt;{{ item.postDate.rfc2822() }}&lt;/pubDate&gt;
    &lt;guid&gt;{{ item.url() }}&lt;/guid&gt;
  &lt;/item&gt;
  {% endfor %}
&lt;/channel&gt;

&lt;/rss&gt;
</code></pre>

<p>If I access, <a href="http://myurl.com/rss" rel="nofollow">http://myurl.com/rss</a> - I get my lovely feed.</p>

CC BY-SA 3.0
2015-10-21T06:35:36.660Z
I've just answered my own question. You can name your file .rss instead of .twig and it automatically sets the `Content-Type` part.
Roel
CC BY-SA 3.0
2015-10-20T15:05:24.427Z
2015-10-20T15:05:24.427Z
Steven Grant
<p>Though this is not a proper answer to the question. If you're unfamiliar with how to use the feeds you may be better off taking a look at the feedMe found plugin here: </p>

<p><a href="https://github.com/engram-design/FeedMe" rel="nofollow">https://github.com/engram-design/FeedMe</a> </p>

<p>And building out your templates using that. Could save some time and headaches. Sorry I can't give you further information on using the feeds as seen in the docs. </p>

CC BY-SA 3.0
2015-10-20T14:52:11.043Z
Thanks, but i am trying to generate a feed instead of importing one.
Roel
CC BY-SA 3.0
2015-10-20T14:34:00.047Z
2015-10-20T14:34:00.047Z
George Dunning
<p>I'm trying to use the native support for rss and atom as described in the documentation, but it misses some info.</p>

<ul>
<li><a href="https://craftcms.com/docs/templating/atom-feed" rel="nofollow noreferrer">https://craftcms.com/docs/templating/atom-feed</a></li>
<li><a href="https://craftcms.com/docs/templating/rss-feed" rel="nofollow noreferrer">https://craftcms.com/docs/templating/rss-feed</a></li>
</ul>

<p>Did anyone got this to work? I'm not even sure how to name my template or what the url is going to be.</p>

<p>I tried the following template names:
<code>template.twig.atom</code>
<code>template.atom.twig</code>
<code>template.atom</code></p>

<p>I tried requests with atom in the header and <code>.atom</code> postfix. Both without any success.</p>

<rss><feed>
Experience with Craft's native rss/atom support?
# Experience with Craft's native rss/atom support?

(Asked by: username_0 on 2015-10-20)

I'm trying to use the native support for rss and atom as described in the documentation, but it misses some info.

* <https://craftcms.com/docs/templating/atom-feed>
* <https://craftcms.com/docs/templating/rss-feed>

Did anyone got this to work? I'm not even sure how to name my template or what the url is going to be.

I tried the following template names:
`template.twig.atom`
`template.atom.twig`
`template.atom`

I tried requests with atom in the header and `.atom` postfix. Both without any success.

**Tags:** rss, feed


---

## 3 answers

### Answer by username_0 on 2015-10-21. Score: 0 | Accepted answer

It turns out that you can call the template file directly and it answers by default with the right response headers.

So for example, putting templates named `feed.atom` and `feed.rss` in the root of your template folder enables you to call them via `/feed.atom` and `/feed.rss`.
No need for setting content-type by hand.


---

### Answer by username_1 on 2015-10-20. Score: 3

Yeah, so I have a rss.twig file in the root of my template directory.
{% header "Content-Type: application/rss+xml" %}



{% set rss = craft.entries.section('article').limit(10).type('article') %}


  My Site Name
  {{ siteUrl }}
  My site description
  en-au
  

  {% for item in rss %}
  
    {{ item.title|raw }}
    {{ item.url() }}
    
    {% for block in item.body %}

  {% if block.type == "text" %}

    {{ block.text }}

  {% elseif block.type == "footnote" %}

    {% include 'blocks/_footnote' %}

  {% elseif block.type == "pullQuote" %}

    {% include 'blocks/_pullquote' %}

  {% elseif block.type == "heading" %}

    {% include 'blocks/_heading' %}

  {% elseif block.type == "image" %}

    {% include 'blocks/_image' %}

  {% elseif block.type == "audio" %}

    {% include 'blocks/_audio' %}

  {% elseif block.type == "video" %}

    {% include 'blocks/_video' %}

  {% endif %}

{% endfor %}
    {{ item.postDate.rfc2822() }}
    {{ item.url() }}
  
  {% endfor %}




If I access, http://myurl.com/rss - I get my lovely feed.

> **Comments:**
> **username_0**: I've just answered my own question. You can name your file .rss instead of .twig and it automatically sets the `Content-Type` part.  

---

### Answer by username_2 on 2015-10-20. Score: 0

Though this is not a proper answer to the question. If you're unfamiliar with how to use the feeds you may be better off taking a look at the feedMe found plugin here:

<https://github.com/engram-design/FeedMe>

And building out your templates using that. Could save some time and headaches. Sorry I can't give you further information on using the feeds as seen in the docs.

> **Comments:**
> **username_0**: Thanks, but i am trying to generate a feed instead of importing one.  

---

