Setting up `org-roam-capture-` to file `org-roam-directory` subdirectories

is there any way to set up org-roam-capture-templates so that these various captures go to different directories?

in org-roam v2, I tried about two months ago to accomplish this with org-roam-extract-new-path to file new capture templates under the ./slips directory, but changing this variable resulted in problems.

Recently, i noticed that subdirectories in the org-roam-directory result in tags being applied automatically to the nodes therein, which is a feature I like a lot. So, when i do org-roam-node-find:

  • the nodes in ./projects have the :projects: tag
  • the nodes in ./topics have the :topics: tag
  • and the nodes in ./slips have the slips tag.

Here’s what my roam directory looks like dcunited001/zettelkasten. I want most things in the ./slips directory, but there are other types of nodes like “topics”, “projects”, “drills” and “code” which i would like to capture, but place in a different subdirectory. The reason is that these are on a different “graph-plane” (an almost separate “plane” in a graph, like control-plane network interfaces). Organizing like this is intuitive for me, but also allows me to make some assumptions about the count of inbound/outbound edges in my roam graph. It is the :topics: and :projects: tags nodes which I would like to “collect” most refs from :slips: tags. Thus, when working on a topic/project:

  • looking at the backlinks buffer for a topic/project should return many nodes
  • eventually i would like to add #+keywords to topics/projects and then maybe analyze text of :slips: nodes to automatically suggest to add backlinks for some topics. this should result in a richer graph with more connections.

I know this may not jive with the org-roam philosophy of all slips going into a single directory, where org-roams sqllite functions fulfill the organizational responsibilities of the filesystem.

For now, I think I can simply prepend project/ or project- to the file+head of newly added capture types.

Specifying the directory in the template like this below has been working with no problems for me. Notice personal directory in the second line after file+head. For work, I have work directory there.

	  ("o" "personal Org" plain "%?" :target
           (file+head "personal/%<%Y-%m-%dT%H%M%S>.org" 
                      ":properties:\n:ID: %<%Y-%m-%dT%H%M%S>\n:modified: <>\n:end:\n#+title: ${title}\n#+filetags: %(downcase (my/insert-category))\n")
           :unnarrowed t)

1 Like

I have been following Org-roam development rather closely and haven’t noticed this feature. I wonder if it is a local enhancement by a distro such as Doom Emacs….

perfect, thanks! I think I can finally start using capture templates for these.

It still needs some tweaking, but here’s what i have:

(setq org-roam-capture-templates
      (append
       ;; org-roam-capture-templates
       '(
         ("p" "projects" plain "%?" :unnarrowed t
          :target (file+head "projects/${slug}.org"
                             "#+title: ${title}\n\n"))
         ("t" "topics" plain "%?" :unnarrowed t
          :target (file+head "topics/${slug}.org"
                             "#+title: ${title}\n\n"))
         ("c" "code" plain "%?" :unnarrowed t
          :target (file+head "code/${slug}.org"
                             "#+title: ${title}\n\n"))
         ("D" "drills" plain "%?" :unnarrowed t
          :target (file+head "drills/${slug}.org"
                             "#+title: ${title}\n\n"))
         ;; TODO: validate whether this should be changed
         ;; - for org-roam-bibtex or org-ref
         ;; NOTE: slug needs to be a DOI in form:
         ;; - ${indicator}.${registrant}/${suffix}
         ("n" "noter (DOI)" plain "%?" :unnarrowed t
          :target (file+head "noter/${slug}.org"
                             "#+title: ${title}\n\n"))

         ("s" "slips" plain "%?" :unnarrowed t
          :target (file+head "slips/%<%Y%m%d%H%M%S>-${slug}.org"
                             "#+title: ${title}"))

         ) org-roam-capture-templates))

I was browsing Daviwil’s dotfiles and found that using the (org-roam-capture- ...) defun may help me split these out into keybinds.