# Linking dynamically new file into Org roam capture template

**URL:** <https://org-roam.discourse.group/t/linking-dynamically-new-file-into-org-roam-capture-template/1866>\
**Category:** How To\
**Created:** [July 30, 2021, 6:13pm UTC](https://org-roam.discourse.group/t/linking-dynamically-new-file-into-org-roam-capture-template/1866 "2021-07-30T18:13:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ELonginus](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ELonginus](https://org-roam.discourse.group/u/ELonginus)\
**Post date:** [July 30, 2021, 6:13pm UTC](https://org-roam.discourse.group/t/linking-dynamically-new-file-into-org-roam-capture-template/1866/1 "2021-07-30T18:13:25Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![magthe](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/magthe/32/851_2.png) [@magthe](https://org-roam.discourse.group/u/magthe)\
**Post date:** [August 1, 2021, 10:02am UTC](https://org-roam.discourse.group/t/linking-dynamically-new-file-into-org-roam-capture-template/1866/2 "2021-08-01T10:02:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ELonginus](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@ELonginus](https://org-roam.discourse.group/u/ELonginus)\
**Post date:** [August 2, 2021, 9:50am UTC](https://org-roam.discourse.group/t/linking-dynamically-new-file-into-org-roam-capture-template/1866/3 "2021-08-02T09:50:21Z")

</div>

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

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

```
