CMS Content RSS feeds

An RSS feed is an important part of your online presence. A feed lets your customers subscribe to your content using popular feed tools, which are used for keeping up to date with weblogs and news sites. Feed readers can help keep your customers connected to your products, your story, marketing, and other important events on your website.

A feed is an XML page that follows a specific format. For example, the RSS 2.0 specification outlines one of the formats supported by today's generation of news and feed readers. LemonStand supports any format of feed, as well as many feed customizations by allowing you to define your feeds in the Twig templates for your store.

This guide shows you how to configure a simple RSS 2.0 feed for your LemonStand store.

Add a RSS Feed Template

As an RSS 2.0 feed is a XML formatted page, you will need to add a new site template to help generate it:

  1. Create a new site template (follow our guide here).
  2. Set the template code to rss-2-0-feed, which is how we'll reference this site template from the page template.
  3. Set the content type to text/xml; charset=utf-8, which signals to the feed reader that this is an XML page.
  4. Add the RSS template code.

The site template defines the outer shell of an RSS 2.0 feed, including the XML header and Content Type. The actual feed content is plugged in by the page template.

RSS 2.0 XML Template Code

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
{{ page() }}
</rss>

Example

The RSS 2.0 Template will look something like this:

Add a RSS site template
RSS 2.0 Site XML Template

You will use your new template for any of the RSS 2.0 feeds on your site. 

Add a main RSS feed

Your store can have more than one XML feed, each will need a different page template and URL. You will need to:

  1. Create a new page template.
  2. Name the page template something memorable (e.g., "Blog RSS feed").
  3. Set the site template to rss-2-0-feed, which is the template we created above.
  4. Set the action to cmscontent:feed, which gives the page access to the CMS content feed variables.
  5. Set the page URL for the feed (e.g., /blog/feed.xml).
  6. Add the feed channel page template content.

Feed Channel Page Template

<channel>
    <title>{{ page.title }}</title>
    <link>{{ page.url }}</link>
    <description><![CDATA[{{ page.description | unescape }} ]]></description>
    <category domain="www.dmoz.com">{{ page.keywords }}</category>
    <lastBuildDate>{{ published_on | date("r") }}</lastBuildDate>
    <pubDate>{{ published_on | date("r") }}</pubDate>
    <generator>LemonStand V2</generator>
{% for post in feed %}
  <item>
    <title>{{ post.title }}</title>
    <link>{{ post.permalink }}</link>
    <description><![CDATA[ {{ post.excerpt | unescape }} ]]></description>
    <pubDate>{{ post.published_on | date("r") }}</pubDate>
  </item>
{% endfor %}
</channel>

The channel template defines the loop of content (blog posts, announcements, etc.) and site metadata used by feed readers for displaying your store's posts and information.

Example

RSS Channel Page Template
RSS 2.0 Channel Page Template