Hand-Coding an RSS Feed

November 2, 2022

Hey Internet.

When I started this site, I made the very intentional decision to code everything by hand rather than relying on some over-complicated framework. Neither I, nor my users need cookies, JavaScript, bloated CSS, and so forth. They don't really add anything of value in my opinion. It's just wasted bandwidth.

For the most part, I feel this has been a good way to go, but RSS has been a thing that I've felt was lacking. I'm not exactly great at making regular posts. Sometimes I'll go months without posting anything, so I couldn't fault anyone for forgetting that this blog even exists. While I don't really care now many people are reading this, I can't expect people to check back regularly on the off chance that I might have posted an update. I feel that RSS is a pretty decent solution to this dilemma. Trouble is, it means I'd need to either start using some sort of CMS, or code the RSS feed by hand.

This isn't the first time I've thought about coding a feed by hand, but I had a look at the spec back in the day and found that so-called "Really Simple Syndication" is anything but, and decided that it was more trouble than it was worth. It ended up just another unfinished (or even started) project... one amongst many, many others. Then I came across this four-year-old video by Chris Were where he'd done exactly that.

I got extra excited when I found that he'd linked a tutorial on how to code a minimalist RSS feed. Sadly, as is often the case with old links, the site seemed to have pivoted to selling WordPress plugins instead, which is basically useless to me. An additional stumbling block was the fact that Chris' website doesn't seem to employ this strategy any more. He seems to have just linked to Fediverse accounts and used their built-in RSS functionality (which is admittedly an easier solution, but not what I want). Nevertheless, this proved to me that what I wanted to do could be done. I just had to do my own research.

The first thing I thought to do was to pause the video when he's showing his RSS code, and that gave me a good start, but I decided I wanted to update it a little by using Atom 1.0, because I expect it'll be a little bit more future-proof, even if it does require a little extra work. Fortunately, the Wikipedia article for Atom has a basic example of an Atom file that I was able to use as a reference point, instead of reading through the whole spec.

While Atom requires a little more work up front, once it's been set up, every time I add another blog entry, I only have to open up the XML file, copy the entry for the previous blog entry, change a couple values, and change the <updated> tag at the top of the file. If you're crazy enough to want to do this yourself, I've got what I think is a pretty lean version of an Atom feed that you can use as a reference. You can find that here. It's also a good idea to add a <link> tag to the head of your HTML document (see line 7 of the source for this page for a reference). If you're not crazy enough to do that... I guess this is just my long-winded way of saying that this blog has an RSS feed now.

Have a good one.