Need help with org-roam-dailies-capture-template

Hello

I am trying to debug a dailies capture template. Here is what I am trying to achieve, I want to create a Dailies template that looks like below when the dailies note doesn’t exist. This is working for me.

#+TITLE: 2022-12-07
#+FILETAGS: daily

* Focus
* Tasks
* Journal

When I try to capture in a note that exists, I want to add a timestamp and a second level heading below journal but that’s not working for me. Here is my setup

(setq org-roam-dailies-capture-templates
        '(("d" "default" entry "* %<%I:%M %p>: %?"
           :target (file+head "%<%Y-%m-%d>.org" "Journal")
           :if-new (file+head "%<%Y-%m-%d>.org"
                              "#+TITLE: %<%Y-%m-%d>\n#+FILETAGS: daily\n\n* Focus\n\n* Tasks\n\n* Journal")
           :unnarrowed t)))

My assumption is that on the line :target (file+head "%<%Y-%m-%d>.org" "Journal") , this should search for a Level 1 Heading called Journal and create a sub entry below this. , But it doesn’t do that. Here is what I get.

#+TITLE: 2022-12-07
#+FILETAGS: daily

* Focus

* Tasks

* Journal
* 01:19 PM: Let's create a timed log here.

Noticed how the time stamped entry is still at Level 1. Any hints on what I am doing wrong will really help.

Thanks,
Vikas

Perhaps add another star ”*”?

I had forgotten to mention that in my post earlier. I had already tried with an extra '*` didn’t seem to make a difference.

I think what you are going for is something like this:

(setq org-roam-dailies-capture-templates
        '(("d" "default" entry "** %<%I:%M %p>: %?"
           :target (file+head+olp "%<%Y-%m-%d>.org"
                                  "#+TITLE: %<%Y-%m-%d>\n#+FILETAGS: daily\n\n* Focus\n\n* Tasks\n\n* Journal"
                                  ("Journal"))
           :unnarrowed t)))

I only tested it lightly but seems to work.

I don’t think :if-new is meant to be used “in addition” to :target – the former is the replacement of the latter and does not mean “If the new note is being created, use A; if not, use target”. I don’t know why two stars didn’t work, though.

That did work - thank you very much.
I didn’t realize that :if-new and :target are not meant to be used together. I had interpreted it to mean exactly what you said. I didn’t realize that :target had superseded :if-new.

Appreciate the help.

2 Likes

If that’s the case should we use :if-new instead of :target? But then, in your examples in this thread, you use :target. I am confused by your statement. Also, I am having trouble in understanding the functionality-wise difference between :if-new and :target.

I think this would have been a mis-statement on my part. My understanding is that they function in the same way, but :target replaces :if-new. I use :target. I believe you can confirm which is the current by looking at the doc string of org-roam-templates.

1 Like