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

**URL:** <https://org-roam.discourse.group/t/setting-up-org-roam-capture-to-file-org-roam-directory-subdirectories/2397>\
**Category:** Troubleshooting\
**Created:** [January 24, 2022, 5:57am UTC](https://org-roam.discourse.group/t/setting-up-org-roam-capture-to-file-org-roam-directory-subdirectories/2397 "2022-01-24T05:57:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aionfork](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@aionfork](https://org-roam.discourse.group/u/aionfork)\
**Post date:** [January 24, 2022, 5:57am UTC](https://org-roam.discourse.group/t/setting-up-org-roam-capture-to-file-org-roam-directory-subdirectories/2397/1 "2022-01-24T05:57:52Z")

</div>

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](https://github.com/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.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [January 24, 2022, 8:23am UTC](https://org-roam.discourse.group/t/setting-up-org-roam-capture-to-file-org-roam-directory-subdirectories/2397/2 "2022-01-24T08:23:25Z")

</div>

> [@aionfork](#):
>
> is there any way to set up `org-roam-capture-templates` so that these various captures go to different directories?

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.

```auto
	  ("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)

```

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [January 24, 2022, 8:26am UTC](https://org-roam.discourse.group/t/setting-up-org-roam-capture-to-file-org-roam-directory-subdirectories/2397/3 "2022-01-24T08:26:12Z")

</div>

> [@aionfork](#):
>
> 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.

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….

---

<div class="post-metadata">

**Author:** ![aionfork](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@aionfork](https://org-roam.discourse.group/u/aionfork)\
**Post date:** [January 24, 2022, 10:06am UTC](https://org-roam.discourse.group/t/setting-up-org-roam-capture-to-file-org-roam-directory-subdirectories/2397/4 "2022-01-24T10:06:48Z")

</div>

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

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

```auto
(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.
