<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"/><metaauthor="Alex Mikhailov"/><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"/><metaname="color-scheme"content="light dark"/><metahttp-equiv="content-language"content="en-us"/><metaname="description"content="Let's add RSS feed to blog"/><metaproperty="og:description"content="Let's add RSS feed to blog"/><metaproperty="og:image"content="https://fidonode.me/resources/images/preview/posts/add_rss_to_blog.org.png"/><metaproperty="og:title"content="Org blog with RSS"/><metaname="twitter:description"content="Let's add RSS feed to blog"/><metaname="twitter:title"content="Org blog with RSS"/><metaname="twitter:image"content="https://fidonode.me/resources/images/preview/posts/add_rss_to_blog.org.png"/><metaname="twitter:card"content="summary_large_image"/><linkrel="icon"type="image/x-icon"href="/resources/favicon.ico"/><linkrel="stylesheet"type="text/css"href="/resources/css/pico.sand.min.css"/><scriptdefer="true"src="https://umami.dokutsu.xyz/script.js"data-website-id="d52d9af1-0c7d-4531-84c6-0b9c2850011f"></script><title>Org blog with RSS</title><linkid="highlight-theme"rel="stylesheet"type="text/css"/><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script><scriptsrc="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/bash.min.js"></script><scriptsrc="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/languages/lisp.min.js"></script><scriptsrc="/resources/js/theme-selector.js"></script></head><body><headerclass="header"><divclass="container"><nav><ul><li><strong>Alex Mikhailov</strong></li></ul><ul><li><ahref="/index.html">About</a></li><li><ahref="/posts.html">Blog</a></li><li><ahref="/rss.xml">RSS</a></li></ul></nav></div></header><mainclass="container blog-post"><hgroup><h1>Org blog with RSS</h1><p>Let's add RSS feed to blog</p><nav><ul><li>Tags:</li><li><mark><ahref="/tags/@org-mode.html"class="secondary">@org-mode</a></mark></li><li><mark><ahref="/tags/@elisp.html"class="secondary">@elisp</a></mark></li><li><mark><ahref="/tags/@rss.html"class="secondary">@rss</a></mark></li></ul></nav></hgroup><divid="table-of-contents"role="doc-toc">
RSS might seem like an outdated, marginal thing. But it still has at least one benefit—you can use an RSS feed as a sitemap for search engines. Plus, it's pretty geeky.
How does it work? As you can see, we use the default sitemap generator from Org Export with some additional steps. By default, the sitemap generator collects all org files from <code>:base-directory</code>. It then places links to these files as separate entries into an intermediate org file and publishes this org file. We use custom functions for collecting entries, formatting entries, and publishing the org file.
Here's the core of the process. We need to prepare entries before feeding them to the <code>org-rss-publish-to-rss</code> function. Since we're doing it our own way, we need to start by creating a bullet with a link to the post, and then add <code>RSS_PERMALINK</code>, <code>RSS_TITLE</code>, and <code>PUBDATE</code>. I also add the first two lines of the blog post instead of a description. This is the native way to do a preview in the RSS world.
This function creates the content of the intermediate org file. Mostly a rudimentary title, and then we ask Org to unwind the list of collected files with the <code>my/format-rss-feed-entry</code> function.