Site Atom Generator


The following Ruby code generates the Atom feed of my website. It is composed of three parts:

Org Mode is told to generate a site.atom file upon execution of this source block. This block is executed when the website is built (or this page exported).

TITLE       = "Adolfo Villafiorita's Homepage"
AUTHOR      = "Adolfo Villafiorita"
DESCRIPTION = "Homepage of Adolfo Villafiorita"
URL         = ""
EMAIL       = ""

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="">
  <title><%= TITLE %></title>
  <link href="<%= URL %>/site.atom" rel="self" type="application/rss+xml" />
  <link href="<%= URL %>"/>
  <updated><%= %></updated>
  <author><name><%= AUTHOR %></name></author>
  <id><%= URL %></id>

  <%- pages.each do |page| -%>
    <title><%= page["TITLE"] %></title>
    <link href="<%= page[:absolute_url] %>"/>
    <id><%= page[:absolute_url] %></id>
    <updated><%= (page["DATE"] ? DateTime.parse(page["DATE"]) : %></updated>
      <%= page["DESCRIPTION"] || page[:excerpt] || "" %>
  <%- end -%>

require 'erb'
load '_scripts/metadata.rb'

pages = Metadata::collect("notes", url: URL).select { |x| x["CATEGORY"] != "index-page" }
renderer =, nil, "-")
content = renderer.result(binding)
puts content