Sitemap

Menu

The following code generates the XML sitemap of my website. It is composed of two parts:

Org Mode is instructed to generate the sitemap.xml file upon execution of this source block. This block is executed when the website is build and this file exported to HTML.

  (require 'templatel)
  (org-babel-load-file "project-specification/metadata.org")

  ;; get metadata of all the files from notes
  (setq metadata (files-metadata "notes" "." "https://ict4g.net/adolfo"))

  (setq atom-template  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
  {% for page in pages %}
  <url>
    <loc>{{ page.ABSOLUTE_URL }}</loc>
    <lastmod>{{ page.DATE_ISO8601 }}</lastmod>
  </url>
  {% endfor %}
</urlset>")

  (templatel-render-string atom-template
                           (list (cons "pages" metadata)))