Chuck Carroll

Creating an RSS feed from scratch

Published: 2022-11-10
Last Updated: 2023-04-13

One of the major grievances/annoyances I've run into with creating a static website by hand is just how manual everything is, including the creation and maintenance of an RSS feed. Whenever I publish a new post, I also have to manually update the "writing" page as well as add a new RSS entry. Although tedious and sometimes annoying (when I forget), it is nonetheless a learning experience and allows me to better understand how these things work.

RSS, in my view, is the superior method to receiving information. It's only content I want to see. No advertisements, no suggested content, and no dark patterns manipulating me into using a platform or website longer than I intended.

What I did was create an empty file called 'feed.xml' and dropped it into the main directory of my website. Here's an example that I've based my RSS feed on. For 'The RSS Feed Title' I put the title of the website. For descrption I put a short description of my website. The last build date tag indicates when the last time the RSS feed was updated and the time must be entered using the RFC 2822 format. The ttl element is 'time to live' which specifies the number of minutes the feed can stay cached before refreshing from source.

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
  <title>Chuck Carroll</title>
  <description>An RSS feed for chuck.is</description>
  <link>https://chuck.is</link>
  <lastBuildDate>
    Wed, 10 Nov 2022 10:00 -0600
  </lastBuildDate>
  <ttl>20000</ttl>
</channel>
</rss>

Currently, there are not any items (ie posts) in this feed. Below is an example post that gets added before the 'channel' and 'rss' closing tags. In this item, the name of the post is "Creating an RSS Feed from Scratch" with a description, link, and publication date. All new items should be added to the top (ie below ttl).

<item>
  <title>Creating an RSS Feed from Scratch</title>
  <description>
     In this post I dive into how to create an RSS feed from scratch.
  </description>
  <link>https://chuck.is/rss</link>
  <pubDate>
    Thu, 10 Nov 2022 10:00 -0600
  </pubDate>
</item>

If you want to include a full HTML post in the entry, within the <description> tag include "<![CDATA[" at the beginning, then drop your HTML content, and then close with "]]>".

The end result of a typically RSS feed looks like this.

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
  <title>Chuck Carroll</title>
  <description>An RSS feed for chuck.is</description>
  <link>https://chuck.is</link>
  <lastBuildDate>
    Wed, 10 Nov 2022 10:00 -0600
  </lastBuildDate>
  <ttl>20000</ttl>

<item>
  <title>Creating an RSS Feed from Scratch</title>
  <description> <![CDATA[
     In this post I dive into how to create an RSS feed from scratch.
     ]]>
  </description>
  <link>https://chuck.is/rss</link>
  <pubDate>
    Thu, 10 Nov 2022 10:00 -0600
  </pubDate>
</item>

</channel>
</rss>

You can view (and subscribe) to my RSS feed at https://chuck.is/feed.xml.

Resources

Thanks for reading. Feel free to send comments, questions, or recommendations to hey@chuck.is.