Author | Jef Meijvis | Publish date | 25/07/2023 |
Title | Creating a RSS feed | Id | 17 |
Source | 017-creating-a-rss-feed.md | Render timestamp | Dec 06, 2023, 06:08:31 AM (GMT+1) |
Views | 22 | Tags | OpenInternet |
Author | Jef Meijvis |
Publish date | 25/07/2023 |
Title | Creating a RSS feed |
Id | 17 |
Source | 017-creating-a-rss-feed.md |
Render timestamp | Dec 06, 2023, 06:08:31 AM (GMT+1) |
Views | 22 |
Tags | OpenInternet |
Share this post:
Recently I added a RSS feed to my personal blogging site. RSS (RDF Site Summary) is a web feed technology, allowing programs to get updates from websites in a standardized fashion. Applications (called aggregators) can collect updates from different RSS sources, and display them in a custom newsfeed. RSS is mostly used for websites that update frequently such as blogs, podcasts and news sites.
Image: RSS Logo
When queried, a RSS feed displays channels containing generic items. This data is provided as a XML file, which then can be read by appropriate applications. Below code snippet is an example of a RSS feed with one channel, containing 2 items:
Code snippet
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
The RSS tag contains channels. Each channel contains multiple items, as well as a bit of general information. The following 3 tags are required for a channel, here filled in with a made-up developer news channel:
Code snippet
1 | |
2 | |
3 | |
4 | |
5 | |
Now if we want to do anything useful with RSS feed, we need to publish some items. An item is a child element of a channel and only needs a required title or description like so:
Code snippet
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
Many other elements can be added to channels and items to include more information. An entire list with useful examples can be found at The RSS Specification.
Since this blog is created using Svelte, I generate the RSS feed on the fly making use of an Sveltekit API endpoint. The source code for this endpoint can be viewed here on Github.
Code snippet
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
I use the following headers to indicate that the request serves a XML file.
Code snippet
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
All in all, RSS is a great technology that is (in my opinion) really under-used. Aggregators availability and browser support for RSS has really shrunk over the past decade. In a time where the battle for an open internet is more relevant than ever (looking at you, Twitter) RSS seems like a great technological standard to allow automatic distribution of website updates.