We Have An RSS Feed!
2023-01-31
I'm excited to say the knusbaum.org now has a RSS Feed. Well, really it's an Atom feed. The two are actually different! But more on that in a moment.
There's something wonderfully simple about an RSS feed. It harkens back to a time before what we now know today as Social Media. A simpler time. A time where everyone had their own little corner of the internet. And if you wanted to share what you were doing, there was a simple, straight-forward way of doing so. Just throw together a little XML file and update it whenever you've got something new. Beautiful.
For a statically generated blog like mine, RSS fits in quite nicely. Maybe one day I'll get around to having something like a Substack. But for right now, I like crafting everything myself by hand. Feels artisanal.
In fact, this whole blog is artisanal. It's generated from markdown files that are parsed by a custom Rust program I wrote. I figured adding some code to generate a "little XML file" would be fairly easy. As it turns out, there are actually a number of details one needs to sort out.
First, you need to figure out what format of feed you want to publish. Generally speaking, what we're trying to do here is something called "Web Syndication". That said, the term RSS is often used interchangeably to mean any form of Web Syndication. I naively thought there was just one standard with different flavors. But as it turns out are two main standards for Web Syndication: RSS (the standard) and Atom. And they have significant differences. RSS the standard is the oldest and most popular but it has a number of issues. The standard has a lot of undefined areas and some silly mistakes in the spec. Atom on the other hand is much more well defined (and, relatively speaking, newer). And because it's a tighter standard, it's easier for developers work with. From one blog post I found on the topic:
Someday if you’re going to create a new feed for some content, please do the web a favor and choose Atom! You’re much more likely to get things right the first time and you’ll make someone else’s job a lot easier.
Say no more. If I can make another developer's life easier, that's great. Atom it is. If we're being pedantic, we'll say this blog has an Atom feed. This mattered because it affected what library I used to generate the feed.
Another interesting rabbit hole I went down is: "what fields should I include in my feed". The Atom standard has only a few required fields for many of it's entities. I looked at several other Atom feeds to see how they do things (shout out to Carlos Bueno and Hugo Landu) and get a feel of what's "normal". I also found the sample feed from the W3C to be quite helpful. Though I wish I'd found the actual Atom spec first, as that also has a good example feed. You can check out my feed to see what fields I ultimately choose to use. I'm notably not providing Summary or Content for each post yet. There's some additional work I'll need to do on my generator in order to support those. I also hope to leverage Category at some point.
Lastly, there's the issue of IDs (namely for the blog posts themselves). The Atom standard specifies all IDs should be IRIs, which is something I'd never heard of before. After doing a little research, I came upon this blog post which was exceptionally helpful. The temptation is to just use the URI/URL for you blog post as the ID for each entry in your Atom feed. However, this can end up backing you into a corner. For entries in your Atom feed, it's really important their IDs are unique and don't change. This allows readers to keep track of entries over time (i.e. mark which ones they've read). But if you ever want to change the way your URLs work for blog, you would then either have to change the IDs in your feed or maintain a mapping back to your old URL generation method. The post above gives a very nice way of generating unique IDs that stay independent of the actual URLs for your posts. That said, I modified it a bit to be even more independent of the post URL.
The funny thing is, I've never actually used an RSS reader myself. Yet after this deep dive I'm definitely more intrigued. I'll be setting one up now, if for no other reason than to test the feed for this blog. But I'm hoping I'll end up with a new, enjoyable way of consuming content.