Creating an RSS feed with Org mode

For a while I've been wanting to add RSS to this site. Not so much because I think the site really needs it, but because it intrigued me to figure out to do it using my existing Emacs Org blogging solution.

In short, I use ox-rss.el (from Org mode's contrib) to produce an RSS feed from the home page. I was delighted that tags on headlines were automatically translated into RSS Categories, with no extra work from me. However, I had to jump some hoops to generate a valid and useful feed.

Only top-level headings become items in the RSS feed. I had to change the headings I used in my index page to get rid of my old top-level headings containing dividing my full list of post into their publication year. Not a big loss, I think, as the URL of each post contains the year already.

I wanted the RSS feed to link to the full article page. To link to the actual post from the RSS feed I had to add RSS_PERMALINK entries to each of the headings in the index page. One slightly annoying bit about this is that I can't use the .org extension like everywhere else, I have to change it to the .html extension it will be when published.

No paragraph content is allowed before the entries. Thirdly, the issue of my index page's introductory text not being allowed in RSS. Solving this was a bit tricky, but I know that Org has a way to tag sections with :noexport: to omit it from being included, and with a bit of searching I found a promising Emacs StackExchange Answer with a macro I was able to adapt to my use. (The macro should be all on one line, but I added line breaks for readability.)

#+MACRO: no-rss (eval
   org-export-current-backend 'rss)
   "* COMMENT :noexport:"

I'm Stig Brautaset.  [...]

What's happening here is that the macro {{{no-rss}}}, when the rss export backend is working on this file, will expand to the headline * COMMENT :noexport: thus making sure that paragraph does not end up in the RSS feed. I have a separate keyword in the file to provide the alternative description (and RSS Image URL) for the feed. That looks like this:

#+DESCRIPTION: I'm Stig Brautaset, and this is my site's RSS feed.

Getting the publication dates right. Getting the publication dates right was just a case of applying elbow grease. To do so all I had to do was to update the PUBDATE property for each entry in the index page to that of the blog post in question. Since I don't have all that many articles this wasn't too difficult. For future posts I'll let ox-rss generate the PUBDATE properties, since adding them to the index will effectively publish them.

Conclusion. So there you go! I think this was all I had to contend with to produce an RSS feed from this blog. I hope you enjoyed this post! It ended up a bit longer than I expected, but there you go.

Posted 22 June 2018 Copyright © Stig Brautaset