Ox-Roam-Backlinks

Published: October 31, 2021

Credit to Ben Mezger & Jethro Kuan for this, just another example of the beautiful compositionality of Emacs. With the right templates it’s easy to set up a quick and easy notes-to-blog pipeline.

1 Org-Roam Capture Template

With a few fields pre-filled for Ox-Hugo we grease the wheels. export_file_name and date are relevant. To keep links in sync internal to Roam and the site the file name and export_file_name should have the same scheme.1

1
2
3
4
5
6
7
8
(org-roam-capture-templates
 `(("d" "default" plain "%?"
    :if-new
	(file+head
     "%<%Y-%m-%d>-${slug}.org"
     "#+title: ${title}
      #+export_file_name: %<%Y-%m-%d>-${slug}\n#+date: %<%Y-%m-%d>")
    :unnarrowed t)))

2 Org-Hugo Dir-Locals

A few local variables the distinguish Org-Roam notes will keep the site neater.

1
2
3
4
5
6
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((org-mode . ((org-hugo-section . "roam")
              (org-hugo-base-dir . "~/Public/blog")
              (org-hugo-auto-set-lastmod . t))))

Ben Mezger gives the method here for representing the backlinks in Hugo. I put it in my ~/Public/blog/layout/roam/ so it applies to the right section of posts.


  1. Perhaps there’s a DRY way to do this. ↩︎