Building an Org Mode Website: Part 5
- Published: July 23, 2025
Adding a List of Pages
So far I have just been manually adding links to index.org for each new blog post. I will still have keep doing that if I want to keep the most recent posts on the main page, but I do not necessarily want to keep the full list on the homepage. One way to automatically build a list like that is to use the sitemap feature in the Org Mode publishing configuration. To do so you need to set :auto-sitemap to non-NIL in org-publish-project-alist for the project that publishes the org files (i.e., not the one just copying any css style files for example. The following includes some additional options that you may want to set:
:auto-sitemap t :sitemap-style list :sitemap-title "Blog Posts" :sitemap-filename "blogs.org" :sitemap-sort-files anti-chronologically
In order to not include index.org in the list of posts, I have created two different projects in org-publish-project-alist, one just for index.org and one for the blog posts.
One difficulty with using the sitemap feature is that it is only generated when you use the 'org-publish-current-project' or 'org-publish-all' functions. My current setup uses 'org-publish-project' and in my limited testing it does not appear to trigger a new generation of the sitemap. So I have added second function much like the first one provided in Part 4:
(defun ks/org-publish-all () (interactive) "A function to use a org-publish-alist from the current directory" (setq ks/store-current-alist org-publish-project-alist) (if (file-exists-p (expand-file-name "org-publish-project.el")) (progn (load (expand-file-name "org-publish-project.el")) (call-interactively 'org-publish-all))) (setq org-publish-project-alist ks/store-current-alist))
Adding a Header and Footer to the Webpages
As we are adding more blog posts to the website it would probably be a good thing to add a menu at the top of each page so one can always navigate back to the home page or the list of posts. In the initial minimum configuration, we set the html-preamble and html-postamble options to the empty string. To set a header or footer for each page we can now take advantage of that option. Here is how a simple navigation menu would look:
:html-preamble "\ <nav> <ul> <li><a href=\"/\">Home</a></li> <li><a href=\"/blogs/blogs.html\">All Posts</a></li> </ul> </nav>" :html-postamble nil
And if desired, you can add text to the postamble option for a footer for each page.