# Capture template from file but only for new entries

**URL:** <https://org-roam.discourse.group/t/capture-template-from-file-but-only-for-new-entries/3114>\
**Category:** How To\
**Created:** [June 15, 2023, 11:52am UTC](https://org-roam.discourse.group/t/capture-template-from-file-but-only-for-new-entries/3114 "2023-06-15T11:52:38Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [July 7, 2023, 5:00pm UTC](https://org-roam.discourse.group/t/capture-template-from-file-but-only-for-new-entries/3114/9 "2023-07-07T17:00:18Z")

</div>

I dug a little deeper by going through the code. I don’t think this is documented, but reading the code, I have realized that you can use a function name instead of a string. So this below works. (If you are interested in where to look, it’s function `org-roam-capture--fill-template`).

 ![Screenshot from 2023-07-07 18-48-56](https://global.discourse-cdn.com/free1/uploads/orgroam/original/2X/3/3b3e1d39a2e811ab89141300372655c1be8ff813.png)

```plaintext
(setq org-roam-capture-templates
      '(("t" "technology" plain "** %?" ;; <= New notes in H2
         :target (file+head+olp my/get-note-file-name ;; <= file name
                                my/get-tech-head ;; <= head (only once for file)
                                ("Note")) ;; H1
         :unnarrowed t)))

(defun my/get-note-file-name ()
  (with-temp-buffer
    (insert-file "~/Documents/temp/filename.org")
    (buffer-substring-no-properties (point-min) (point-max))))

(defun my/get-tech-head ()
  (with-temp-buffer
    (insert-file "~/Documents/temp/head.org")
    (buffer-substring-no-properties (point-min) (point-max))))

```

`~/Documents/temp/filename.org`

```plaintext
%<%Y%m%d%H%M%S>-${slug}.org

```

`~/Documents/temp/head.org`

```plaintext
#+title: ${title}
#+author: Name

* Note
:properties:
:CATEGORY: notes
:end:

```

---

_[View the full topic](https://org-roam.discourse.group/t/capture-template-from-file-but-only-for-new-entries/3114)._
