Home > Shopify Development > Insert an RSS or Atom feed on the Jekyll site

How to insert an RSS or Atom feed on the Jekyll site in Shopify

Sam Nguyen
Sam Updated: February 19, 2024

Share:

Drive 20-40% of your revenue with Avada
avada email marketing

An RSS or Atom feed is considered very important for most blogs to notify their readers/ viewers of new content on the site. More into details, there are two ways to add an RSS or Atom feed to your Jekyll site: either using a Jekyll plugin or Liquid. We highly recommend the plugin for you because it should be the most effective way for the reason that there are thousands of people have tested the code. Nevertheless, you should also have a look at the RSS using pure Liquid to understand more how it really works.

For your information, an RSS feed is an XML document that has basic metadata on a site, followed by an item list of content (blog posts, usually) which have a title, publish date, description, and link, in a typical way.

This is an example of a simple RSS feed:


<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>RSS Feed Exmple</title>
    <description>RSS is a fascinating technology. The uses for RSS are expanding daily.</description>
    <link>http://www.feedforall.com/industry-solutions.htm</link>
    <item>
      <title>RSS Solutions for Restaurants</title>
      <description>FeedForAll helps Restaurants communicate with customers. Let your customers know the latest specials or events.</description>
      <link>http://www.feedforall.com/restaurant.htm</link>
      <comments>http://www.feedforall.com/forum</comments>
      <pubDate>Tue, 19 Oct 2004 11:09:11 -0400</pubDate>
    </item>
    <item>
      <title>RSS Solutions for Schools and Colleges</title>
      <description>FeedForAll helps Educational Institutions communicate with students about school wide activities, events, and schedules</description>
      <link>http://www.feedforall.com/schools.htm</link>
      <comments>http://www.feedforall.com/forum</comments>
      <pubDate>Tue, 19 Oct 2004 11:09:09 -0400</pubDate>
    </item>
  </channel>
</rss>

However, to help you deeply understand, this instructional writing on how to insert an RSS or Atom feed on the Jekyll site will be a great help. Please follow these two methods below to find out the best solution for you.

How to insert an RSS or Atom feed on the Jekyll site

Method 1: Using Liquid

In specific, by using Liquid you are able to output an XML file with this format for the site. To begin, you need to create /feed.xml with the content given below:


---
layout: null
---
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Bakery Store - Articles</title>
    <description>Your latest baking news</description>
    <link>{{ site.url }}</link>
    {% for post in site.posts %}
      {% unless post.draft %}
        <item>
          <title>{{ post.title | xml_escape }}</title>
          <description>{{ post.content | xml_escape }}</description>
          <pubDate>{{ post.date | date_to_xmlschema }}</pubDate>
          <link>{{ post.url | prepend: site.url }}</link>
          <guid isPermaLink="true">{{ post.url | prepend: site.url }}</guid>
        </item>
      {% endunless %}
    {% endfor %}
  </channel>
</rss>

This will loop over the blog posts and output metadata in a format of RSS XML. There could be a variable site.url not defined yet but you could define it in _config.yml.


...
url: http://bakery-store.example.com
...

To end the process, please add a link to the RSS fwwd to <head> in _layouts/default.html.


...
<link rel="alternate" type="application/rss+xml" title="Bakery Store RSS" href="/feed.xml">
...

Now you can see the full feed when you go to /feed.xml


<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Bakery Store - Articles</title>
    <description>Your latest baking news</description>
    <link>http://bakery-store.example.com</link>
        <item>
          <title>Where Did The Cookie Come From</title>
          <description>&lt;p&gt;The chocolate chip cookie was invented by Ruth Graves Wakefield. She owned the Toll House Inn, in Whitman, Massachusetts, a very popular restaurant that featured home cooking in the 1930s. Her cookbook, Toll House Tried and True Recipes, was first published in 1936 by M. Barrows &amp;amp; Company, New York. The 1938 edition of the cookbook was the first to include the recipe “Toll House Chocolate Crunch Cookie” which rapidly became a favorite cookie in American homes.&lt;/p&gt;

&lt;p&gt;Source / Read more &lt;a href=&quot;https://en.wikipedia.org/wiki/Chocolate_chip_cookie&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
</description>
          <pubDate>2016-01-02T00:00:00+13:00</pubDate>
          <link>http://bakery-store.example.com/information/2016/01/02/where-did-the-cookie-come-from.html</link>
          <guid isPermaLink="true">http://bakery-store.example.com/information/2016/01/02/where-did-the-cookie-come-from.html</guid>
        </item>
        <item>
          <title>What Is Sour Dough</title>
          <description>&lt;p&gt;Sourdough bread is made by the fermentation of dough using naturally-occurring lactobacilli and yeast. Sourdough bread has a mildly sour taste not present in most breads made with baker’s yeast and better inherent keeping qualities than other breads, due to the lactic acid produced by the lactobacilli.&lt;/p&gt;

&lt;p&gt;Source / Read more &lt;a href=&quot;https://en.wikipedia.org/wiki/Sourdough&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
</description>
          <pubDate>2016-01-01T00:00:00+13:00</pubDate>
          <link>http://bakery-store.example.com/information/2016/01/01/what-is-sour-dough.html</link>
          <guid isPermaLink="true">http://bakery-store.example.com/information/2016/01/01/what-is-sour-dough.html</guid>
        </item>    
  </channel>
</rss>

Method 2: Jekyll-feed plugin

Now we are going to move to Jekyll-feed plugin, another method. In the root of the site, please create Gemfile and add the jekyll-feed and jekyll gem:


source 'https://rubygems.org'

gem 'jekyll'

group :jekyll_plugins do
  gem 'jekyll-feed'
end

Then, we are able to use a Liquid tag from the plugin instead of adding a <link> to RSS in the layout like the previous section:


...
{% feed_meta %}
...

Finally, install jekyll-feed and run jekyll with bundle exec by running bundle install on the command line:


bundle exec jekyll serve

We will get a feed of out posts when navigating to /feed.xml on the live site.


<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <generator uri="http://jekyllrb.com" version="3.1.2">Jekyll</generator>
  <link href="http://bakery-store.example.com/feed.xml" rel="self" type="application/atom+xml" />
  <link href="http://bakery-store.example.com/" rel="alternate" type="text/html" />
  <updated>2016-05-13T16:22:08+12:00</updated>
  <id>http://bakery-store.example.com/</id>
  <entry>
    <title>Where Did The Cookie Come From</title>
    <link href="http://bakery-store.example.com/information/2016/01/02/where-did-the-cookie-come-from.html" rel="alternate" type="text/html" title="Where Did The Cookie Come From" />
    <published>2016-01-02T00:00:00+13:00</published>
    <updated>2016-01-02T00:00:00+13:00</updated>
    <id>http://bakery-store.example.com/information/2016/01/02/where-did-the-cookie-come-from</id>
    <content type="html" xml:base="http://bakery-store.example.com/information/2016/01/02/where-did-the-cookie-come-from.html">&lt;p&gt;The chocolate chip cookie was invented by Ruth Graves Wakefield. She owned the Toll House Inn, in Whitman, Massachusetts, a very popular restaurant that featured home cooking in the 1930s. Her cookbook, Toll House Tried and True Recipes, was first published in 1936 by M. Barrows &amp;amp; Company, New York. The 1938 edition of the cookbook was the first to include the recipe “Toll House Chocolate Crunch Cookie” which rapidly became a favorite cookie in American homes.&lt;/p&gt;

&lt;p&gt;Source / Read more &lt;a href=&quot;https://en.wikipedia.org/wiki/Chocolate_chip_cookie&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
    </content>
    <category term="Information" />
    <summary>The chocolate chip cookie was invented by Ruth Graves Wakefield. She owned the Toll House Inn, in Whitman, Massachusetts, a very popular restaurant that featured home cooking in the 1930s. Her cookbook, Toll House Tried and True Recipes, was first published in 1936 by M. Barrows &amp;amp; Company, New York. The 1938 edition of the cookbook was the first to include the recipe “Toll House Chocolate Crunch Cookie” which rapidly became a favorite cookie in American homes.</summary>
  </entry>
  <entry>
    <title>What Is Sour Dough</title>
    <link href="http://bakery-store.example.com/information/2016/01/01/what-is-sour-dough.html" rel="alternate" type="text/html" title="What Is Sour Dough" />
    <published>2016-01-01T00:00:00+13:00</published>
    <updated>2016-01-01T00:00:00+13:00</updated>
    <id>http://bakery-store.example.com/information/2016/01/01/what-is-sour-dough</id>
    <content type="html" xml:base="http://bakery-store.example.com/information/2016/01/01/what-is-sour-dough.html">&lt;p&gt;Sourdough bread is made by the fermentation of dough using naturally-occurring lactobacilli and yeast. Sourdough bread has a mildly sour taste not present in most breads made with baker’s yeast and better inherent keeping qualities than other breads, due to the lactic acid produced by the lactobacilli.&lt;/p&gt;

&lt;p&gt;Source / Read more &lt;a href=&quot;https://en.wikipedia.org/wiki/Sourdough&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
    </content>
    <category term="Information" />
    <summary>Sourdough bread is made by the fermentation of dough using naturally-occurring lactobacilli and yeast. Sourdough bread has a mildly sour taste not present in most breads made with baker’s yeast and better inherent keeping qualities than other breads, due to the lactic acid produced by the lactobacilli.</summary>
  </entry>
</feed>

All the fields can be customized at any time. Also, you are allowed to add extra metadata like the author.

Conclusion

We hope that you would find this instruction helpful. For more information, please check out more of our related posts to get what you are looking for.


Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.

Stay in the know

Get special offers on the latest news from AVADA.