Skip to content

Create an Atom Feed

johnmuhl edited this page Aug 24, 2010 · 5 revisions

Create a new layout called Atom Feed click the More link and enter application/atom+xml for the context-type area. In the body enter:

<r:content/>

Create a new page called “News Feed”, click the More link and set the slug to news.atom in the body part enter:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us">
  <id>http://example.com/blog/</id>
  <title type="text"><r:title/></title>
  <updated>
    <r:find url="/blog">
      <r:children:each limit="1" order="desc">
        <r:date for="updated_at" format="%Y-%m-%dT%H:%M:%SZ"/>
      </r:children:each>
    </r:find>
  </updated>
  <author>
    <name>Your Name</name>
    <uri>http://example.com/contact/</uri>
  </author>
  <link rel="self" type="application/atom+xml" href="http://example.com<r:url/>"/>
  <link rel="alternate" type="text/html" href="http://example.com/blog/"/>
  <generator>Radiant CMS</generator>
  <r:find url="/blog">
    <r:children:each order="desc">
      <r:unless_content part="ignore">
        <entry>
          <id>http://example.com/blog/<r:slug/>/</id>
          <title type="html"><r:escape_html><r:title/></r:escape_html></title>
          <updated><r:date for="updated_at" format="%Y-%m-%dT%H:%M:%SZ"/></updated>
          <content type="html"><r:escape_html><r:content/></r:escape_html></content>
          <link rel="alternate" type="text/html" href="http://example.com/blog/<r:slug/>/"/>
          <r:if_content part="extended">
            <summary><r:content part="extended"/></summary>
          </r:if_content>
          <published><r:date for="published_at" format="%Y-%m-%dT%H:%M:%SZ"/></published>
        </entry>
      </r:unless_content>
    </r:children:each>
  </r:find>
</feed>

Adjust where necessary. Add a page part called ignore, set the layout to Atom Feed.

Now wherever you have the HTML <head> of your site, add:

<link href="/news.atom" rel="alternate" title="News Feed" type="application/atom+xml">
Clone this wiki locally
You can’t perform that action at this time.