Sitemap
The following code generates the XML sitemap of my website. It is composed of two parts:
- the first part reads the metadata from all files in my homepage
- the second part uses
templatel
to generate the sitemap
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)))