Linking dynamically new file into Org roam capture template

Hello I am new. I want to ask how do I link to a file in v2 in my template ?

I got a template called Book which will link to a journal file of today when i create the capture. With file link i can be done with something like [file:~/org/roam/%<%Y%m%d>][%<%Y%m%d>]

But given now that links are generated with a id, i cant do something like that. How do I do that in v2 ?

I think it’s possible to give a node any id you want, so maybe it’s easier to make sure the journal file gets a fitting I’d instead?

I ended up writing this function which allows me to get the node id of the file using the title

(defun azr/print-node-link (title)
  "Insert a org-roam-node-link to a title if the file is found, if not print the title as it is"
  (let* ((nd (org-roam-node-from-title-or-alias title)) )
  (if nd
        (let* ((ID (org-roam-node-id nd)))
        (print (format " [[id:%s][%s]]" ID title)))
    (print title))
))

1 Like