How to Build an RSS Feed

How to Build an RSS Feed

To Share your Published Content to a Broad Audience

Share your Published Content to a Broad Audience

RSS stand for Really Simple Syndication, and it is currently in its second generation of specification. It is a format for sharing data between websites, based on the pre-JSON data exchange format, XML.

Why Use RSS

RSS feeds are very common in publishing — from small personal blogs to the New York Times. This is because they offer a standard format that allows publication information to be shared more easily from site to site and from site to users.

An RSS feed is just an XML file, containing a long list of <item> tags that each contain information about a published article. For example:

<item>
  <title>'The Daily' explores a Covid mystery in Africa.</title>
  <link>https://www.nytimes.com/2022/04/07/world/africa/the-daily-explores-a-covid-mystery-in-africa.html</link>
  <guid isPermaLink="true">https://www.nytimes.com/2022/04/07/world/africa/the-daily-explores-a-covid-mystery-in-africa.html</guid>
  <atom:link href="https://www.nytimes.com/2022/04/07/world/africa/the-daily-explores-a-covid-mystery-in-africa.html" rel="standout"/>
  <description/>
  <pubDate>Thu, 07 Apr 2022 19:21:28 +0000</pubDate>
  <media:content height="151" medium="image" url="https://static01.nyt.com/images/2022/04/07/world/07virus-briefing-daily-01/07virus-briefing-daily-01-moth.jpg" width="151"/>
  <media:credit>Finbarr O'Reilly for The New York Times</media:credit>
  <media:description>A man received a Covid vaccine shot in Sierra Leone in February.</media:description>
</item>

The format has evolved over time to contain more content, one addition to the XML is the <atom:link> tag. Technically Atom was a whole new specification that was later incorporated into RSS because it wasn’t successful.

In essence,

RSS feeds offer a highly standardized method of sharing lists of articles/publications that can be consumed by other applications.

This is a very simple but very powerful standardization. Because RSS provides an interface that is dependable, a whole industry has evolved around creating RSS Reader applications: simply apps that allow you to ‘subscribe’ to RSS feeds, and then read through the content in that article.

Build an RSS Feed

Building a feed is not overly complicated. All you need to do is follow the syntax that is laid out for you by the specification. You’ll need to start with the XML tag, and then the primary RSS tag, and then the <channel> tag which is the primary content of the feed.

<?xml version="1.0" ?>
<rss version="2.0">
<channel>
  // Your content here
</channel>

Within many RSS feeds you will see a property called “xmlns” (<html xmlns=”http://www.w3.org/1999/xhtml">) This stands for XML namespace and it is a way to define namespaces within your RSS feed. It’s generally used to add tags from other specifications to your RSS feed. For example, the Dublin Core specification defines a few useful tags that we might want to add to our XML. We can add that specification url to the rss header like so: <rss xmlns:dc=”http://purl.org/dc/elements/1.1/”> and then use the elements in the following XML like so: <dc:creator>Alex Z></dc:creator>.

Within the <channel> tag you will first assign metadata for the RSS Feed using the following tags. This is information about the feed itself rather than any individual article.

<title> </title>
<link> </link>
<image>
  <url>https://www.demo.com/fun.gif</url>
  <link>https://www.demo.com/index.php</link>
</image>
<description>All you need to  know about RSS</description>

Then you will start adding items, like below. For a full list of the properties that can be assigned to the item tag you can see the following list.

<item>
  <title></title>
  <link></link>
  <description></description>
  <author>….</author>
  <category>….</category>
  <comments>….</comments>
  <enclosure./>
  <guid>….</guid>
  <pubDate>….</pubDate>
  <source>….</source>
</item>

Now of course in a real production scenario you’ll need to generate this information programmatically so that you aren't’ sitting around manually updating your RSS feed whenever new content becomes available, but this is the basic process of building an RSS feed.

Once your feed is finished, you can test your feed using an online tool like this one by W3C. Once your feed is validated you should be off to the races!

Thanks for reading!

Sources:

  1. RSS tutorial: building and using a feed, step by step. (xul.fr)
  2. https://www.rssboard.org/rss-history
  3. https://validator.w3.org/feed/docs/rss2.html

Did you find this article valuable?

Support Alexander Zito-Wolf by becoming a sponsor. Any amount is appreciated!