How to capture to org daily under a specific heading

Hello,

I was following this article to create daily journal entries, and they shared this capture template:

(setq org-roam-dailies-capture-templates
      '(("d" "default" entry "* %<%I:%M %p>: %?"
         :if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))

How can I modify this so that the timestamped entry would be placed under a heading in the daily org file.

For example:

* Notes
** 10:00 AM: Figured out how to capture entries under the "Notes" heading!
1 Like

I believe this might help; you’d need to tweak it a little.

Thanks! That worked!

Writing this here in case it helps others: I couldn’t find any documentation in the manual for the file+head+olp or even file+head target type. It turns out that the description for these is in the org-roam-capture-templates variable docstring.

@troam Can you please share your final code?

@nobiot Is it possible to take the heading under which I want to add the subheading as an input from the user rather than hardcoding it to a particular value?

Here’s what I’m using:

(setq org-roam-dailies-capture-templates
      '(
        ("l" "Daily Log Entry" entry "** %<%I:%M %p>: %?"
         :target (file+head+olp "%<%Y-%m-%d>.org"
                                "#+title: %<%Y-%m-%d>\n\n* Log\n:PROPERTIES:\n:VISIBILITY: children\n:END:\n"
                                ("Log"))
         :unnarrowed t)

        ))

1 Like

Based on @troam, you can replace "Log" with "%^{prompt}" according to the documentation string of org-roam-capture-templates, like this below.

It works on my end. You can change the “Type node” in the way you want.

(setq org-roam-dailies-capture-templates
      '(("l" "Daily Log Entry" entry "** %<%I:%M %p>: %?"
         :target (file+head+olp "%<%Y-%m-%d>.org"
                                "#+title: %<%Y-%m-%d>\n\n* Log\n:PROPERTIES:\n:VISIBILITY: children\n:END:\n"
                                ("%^{Type node}"))
         :unnarrowed t)))
1 Like

@troam @nobiot Thank you so much for being helpful. This works for me. Although, I realized that I have to type in the exact heading or else it creates a new one instead of failing). Is there a way to rather let me choose from the existing headlines in the file? Or fail instead of creating a new one, thereby making sure no unnecessary headlines are created.

1 Like

I think that you’d need to code your own thing if you really need a solution exactly as you describe.

If you have a few headlines for this capture and know what they are beforehand, you can list them in the capture template and select one when you capture a new note.

If interested, I suggest you to refer to this part of documentation string of org-roam-capture-templates: