Want to hand-code your own RSS feed for some god-damned reason? Same here! And after a ton of trial and error, I finally have a working RSS feed. (It’s technically an Atom feed, but “RSS” is the Kleenex of XML, if you know what I mean.) In order to prevent myself from the headache of recreating this in the future — and to possibly help others — I’ve created a simple template below.
This began as a riff on the web feed cheat sheet from tiny-universes.net. That’s a great starting point, if you’re looking to just get a basic RSS feed set up. But my version has several key modifications I picked up from Ruby May Valentine.
Ruby seemingly invented a new form of posting called “rosting.” Essentially, it’s posting content directly to an RSS feed that is unassociated with any content elsewhere on the internet. Only those who are subscribed to your RSS feed can see this special, exclusive content. It’s essentially like tweeting directly to an extremely niche audience of people who use RSS readers and subscribe to your content, and I think that’s super rad.
The big issue that I had when trying to do this myself was that RSS requires each item within the feed to have a unique ID. Typically that ID would be a URL that links directly to where that item exists online. (A direct link to a blog post, for example.)
One of the big things about rosts is that they do not exist elsewhere online. My first attempt at solving this problem was just using my main URL as all of the IDs. But again, each ID has to be unique, so that didn’t work. I finally went back to the source and saw Ruby’s solution, which is this bit of code:
<guid isPermaLink="false">rost01</guid>
This communicates that this item does not have a permanent link and then assigns rost01 as the ID. You would then update that number for each of your individual rosts, meeting the mandate that each item has a unique ID. Easy! Genius!
Another issue I had was formatting my posts. There are a few ways to solve this, but the one I’m running with seems to be pretty common. Things can get wonky fast. But using this below code unlocked all the formatting options that I personally need:
![CDATA[ <p>{POST CONTENT}</p> ]]
That CDATA bit allows for some HTML. You can add simple text formatting, like bold and italics. And even embed hyperlinks and images, as you normally would. The only quirk is that you need to close certain tags a little differently. Like this, for images:
<img src="example.jpg" alt="example alt text"/>
Another thing you’ll need to get used to is the required timestamp formatting. This setup uses the <pubdate> tag and is pretty specific. You have to use the correct day of the week, correct three-letter month abbreviation, and a timestamp. I don’t care if my timestamps are accurate, so I always use a cool time like 04:20:00. Here’s an example:
Mon, 16 Sep 2024 04:20:00 CDT
The rest should hopefully be self-explanatory. Just replace the highlighted bits with your information. Be sure to use full, proper links. (Don’t use relative links for maybe obvious reasons.) This is a very basic setup that’s about as simple as possible. Once you get comfortable with this, you may want to look into adding other elements in order to create the RSS feed of your dreams.
Also, a few bits are optional. For example, you can delete the <title> element and just use the <description> to house all of your content. (This is a bit more like a tweet. Those didn’t have “titles.”)
Lastly, be sure to run your feed through a validator to spot any issues. (This one has a direct input option so you can check your feed before actually publishing it.) And subscribe to your own feed to make sure it operates as intended. It’s very easy for things to get janky, in my experience. And if you mess up and have to fix something, it’ll sometimes create duplicate posts in your subscriber’s reader. While figuring this all out, I created a huge mess of my feed and had to remove and add it back to fix things. Best to avoid making such messes, if possible.
ALSO: If you want your RSS feed to be discoverable from your homepage, be sure to drop the following bit of HTML into the <head> of your homepage:
<link
rel="alternate"
type="application/rss+xml"
href="/feed.xml"
title="RSS Feed">
This will allow someone to add your main URL into most feed readers, instead of needing to use the URL directly to your feed. Handy!
The Template
The actual template is below. Simply copy and paste the text, replace the highlighted bits, and save as an .XML file. Duplicate the <item> section as needed to make your posts, just make sure to keep up the structure and keep an eye on those unique IDs.
Hopefully it works for you. This is essentially the extent of my knowledge, but if you run into issues or see obvious errors, feel free to email me at mattcolewilson@gmail.com. Also check out this link that covers all the RSS specifications: https://www.rssboard.org/rss-specification
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>{TITLE}</title>
<description>{DESCRIPTION}</description>
<link>{WEBSITE URL}</link>
<atom:link href="{FEED URL}" rel="self" type="application/rss+xml"/>
<item>
<title>{POST TITLE}</title>
<description>
<![CDATA[ <p>{POST CONTENT}</p> ]]>
</description>
<pubDate>{DATE AND TIME}</pubDate>
<link>{WEBSITE OR POST URL}</link>
<guid isPermaLink="false">{UNIQUE ID}</guid>
</item>
</channel>
</rss>