Quick Tip: Validate your site's RSS feed with XML Starlet
Hey internet. Here's a quick tip. If you're reading this you've probably found my website through neocities. Maybe Mastodon. This means there's a very high chance that you're a nerd who has/is considering getting your own website, maybe you like zines, might have strong appreciation of font choices, perhaps opinions about text editors, and you probably like RSS feeds.
Don't know what RSS is?
If you're unaware of what an RSS feed is, I'm going to go ahead and say the fact that you're even at this page means you're probably exactly the sort of person who would enjoy RSS feeds. Read about 'em here. If you have your own Neocities site, you actually already have an RSS feed of your site updates, provided by Neocities. But, maybe you maintain your own one separately. Maybe you use some sort of program or script to generate one for you. If you run a site/blog but don't have a feed, you should get one! It's a cool feature of the independent web.
Oh fickle technology
In the past week I have on two different occasions encountered a broken feed. RSS (and Atom) are making a bit of a come back it seems, but they're still a little niche and often people don't get any metrics on activity there. So if it breaks, unless someone in the probably smallish audience says something you just might not know. I know one of those two cases was someone hand-editing their feed, I don't know what the other case was. And personally, this made me a little paranoid. I use (a cutomized version of) makesite to generate this blog and it works pretty damn well but it's not impossible that there's some niche case where I'll break my damn feed and maybe not notice (Although, I do keep my own feed in my own newsreader. I'm just that egomaniacal).
So, I added a quick validation check to my deploy script. And thought I'd share this with anyone else out there using bash as part of their static site generation, and appreciates a good validation check (I already established that if you're reading this, you're probably a damn nerd, don't deny it).
You said this was a 'quick tip', give me the goods!
Fine here's the gist. There's an XML tool called XML Starlet. Get it via your apt-get, flatpak, snap, dnf, brew, pkg, pkg_add, wget, or rm command. Once you do we're going to get an XML schema so that XML Starlet knows the RSS rules. I found this one here. Here's another I found for Atom, if you use that Go ahead and put that in some file called rss.xsd or whatever, in an appropriate folder for your website's build system. All you need to do now, is put into your bash file:
set -e
xmlstarlet val -e -s path/to/rss.xsd path/to/rss.xml
With the appropriately edited paths there instead obviously. The "set -e" means the script will abort if your check fails. Note that this will cause your script to abort if any following command errors. That seems like reasonable behaviour to me but if that isn't good for you, you can research how to abort on a specific failure. "An exercize for the reader", as we lazy authors say.
That's it. You're done. Congrats. Why don't you reward yourself by, hmmm, perhaps adding this link to your newsreader? https://mosfetarium.com/blog/rss.xml. I wonder what it could be! Could great wisdom and entertainment come from this feed in the future?! Only one way to find out!