Changes in the sitemap and structure of the blog

I want a diffrent sitemap

From the begining I wanted to have a auto generated sitemap that shows date the blog post was generated and a category of the post.
Finaly I did it. Although it is not perfect, it works for now. This wasn't easy for a Emacs Newbee like me :)!

new_sitemap.jpg

This Elisp code I hacked together from different sites did the trick.

(defun my-site-format-entry (entry style project)
  (format "%s - [[file:%s][%s]] (%s)"
          (format-time-string "%Y-%m-%d" (org-publish-find-date entry project))
          entry
          (org-publish-find-title entry project)
          (org-find-category (expand-file-name entry (plist-get (cdr project) :base-directory)))))

(defun org-find-category (file)
  (with-temp-buffer
    (insert-file-contents file)
    (goto-char (point-min))
    (let ((beg (+ 1 (re-search-forward "^#\\+CATEGORY\:")))
          (end (progn (forward-word) (point))))
      (buffer-substring beg end))))

Just call that from :sitemap-format-entry in your publishing config. It will pull the #+TITLE, #+DATE and #+CATEGORY parameters from the org files.

Happy Hacking!!!

License: CC BY-SA 4.0 Discuss on Mastodon