Recently, I chose to revamp this website using Hugo, due to its relative ease of use and its native support for Org Mode files. Since I have been using Org-roam to manage my personal knowledge base, I thought it would be useful to be able to write blog posts directly as Org-roam notes.

By default, Hugo and Org-roam use incompatible tagging systems. Hugo's tag system expects a #+tags[]: property in the front matter, while Org-roam expects a #+roam_tags: property.

This is a relatively easy problem to solve. According to Org-roam's documentation, file tag extraction can be customized. Since #+tags[]: and #+roam_tags: can be used in a compatible manner (avoid using whitespace in tags), we can copy the default #+roam_tags: handler (#+org-roam--extract-tags-prop) and tweak it to look for #+tags[]: instead.

;; Based on code from Org-roam, licensed under GNU GPLv3 or higher.
;; This code is distributed without any warranty.
(defun org-roam--extract-tags-hugo (_file)
  "Extract tags from the current buffer's \"#+tags[]\" global property."
  (let* ((prop (or (cdr (assoc "TAGS[]" (org-roam--extract-global-props '("TAGS[]"))))
    (condition-case nil
        (split-string-and-unquote prop)
         (lwarn '(org-roam) :error
                "Failed to parse tags for buffer: %s. Skipping"
                (or org-roam-file-name

Now all we have to do is append hugo to the org-roam-tag-sources list.

 '(org-roam-tag-sources '(prop hugo)))

By default, Hugo ignores #+roam_tags: properties in the front matter, which means we can use them to add tags we don't want to export. For example, I prepend blog posts with #+roam_tags: blog so that I can filter them while using Org-roam Server.