# Page template from new ref

**URL:** https://community.silverbullet.md/t/page-template-from-new-ref/3848
**Category:** General
**Created:** [February 7, 2026, 8:48am UTC](https://community.silverbullet.md/t/page-template-from-new-ref/3848 "2026-02-07T08:48:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jeroen](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://community.silverbullet.md/u/jeroen)
#### Post date: [February 7, 2026, 8:48am UTC](https://community.silverbullet.md/t/page-template-from-new-ref/3848/1 "2026-02-07T08:48:24Z")

</div>

I've got a page template for persons, which I use with a command button. Each person has its own subpage. I ref persons in notes by typing [[persons/mike]]

But sometimes i need to create a new person super quick while in a note. If I ref a person that doesn't exist, that creates a new empty page in /person. However that new page is blank instead of populated by a person template.

Q: is it possible to run a person template when a new page is created? For example triggering because it's in a sub folder of /person? Alternative solutions are also welcome :).

---

<div class="post-metadata">

### Author: ![Mr.Red](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mr.red/32/821_2.png) [@Mr.Red](https://community.silverbullet.md/u/Mr.Red)
#### Post date: [February 7, 2026, 4:50pm UTC](https://community.silverbullet.md/t/page-template-from-new-ref/3848/2 "2026-02-07T16:50:13Z")

</div>

You could check out and customize this script for you use case:

> [@Sleek interactive Floating Journal Calendar](https://community.silverbullet.md/t/sleek-interactive-floating-journal-calendar/3680/31):
>
> here is the event listener to evaluate the functions before inserting them to the page this way you can add functions to your template which will be then interpreted before applying them to your page: event.listen { name = "editor:pageCreating", run = function(e) if not e.data.name:startsWith("Journal/") then return end local rawTemplate = space.readPage("Library/Custom/New\_Journal\_Template") local tree = markdown.parseMarkdown(rawTemplate) local expandedTree = m…

> ⚠ **NOTE** ⚠  
> This script doesn't use the Silverbullet Page Templates, but a simple page with functions in it, so you don't need to add the "special" frontmattr to the template, just the things you want the page to be prepopulatd with.

---

<div class="post-metadata">

### Author: ![jeroen](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://community.silverbullet.md/u/jeroen)
#### Post date: [February 7, 2026, 4:57pm UTC](https://community.silverbullet.md/t/page-template-from-new-ref/3848/3 "2026-02-07T16:57:58Z")

</div>

I need some time and a pc to grasp this, but thanks again @Mr.Red. You're on fire

---

<div class="post-metadata">

### Author: ![Mr.Red](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mr.red/32/821_2.png) [@Mr.Red](https://community.silverbullet.md/u/Mr.Red)
#### Post date: [February 7, 2026, 5:03pm UTC](https://community.silverbullet.md/t/page-template-from-new-ref/3848/4 "2026-02-07T17:03:23Z")

</div>

it is as simple as this:

copy/paste this into a space-lua codeblock

```lua
event.listen {  
  name = "editor:pageCreating",  
  run = function(e)  
    if not e.data.name:startsWith("persons/") then return end  
    local rawTemplate = space.readPage("Library/Custom/New_Person_Template")  
    local tree = markdown.parseMarkdown(rawTemplate)  
    local expandedTree = markdown.expandMarkdown(tree)  
    local template = markdown.renderParseTree(expandedTree)  
    return { text = template, perm = "rw" }  
  end  
}

```

and create a template page like this for example `Library/Custom/New_Person_Template`:

```auto
---
name: "|^|"
phone: ""
birthday: ""
image_url: ""
---

# Hobbies
- 
-
...

```

In the template’s text, you can optionally use `|^|` as a placeholder for where the cursor should be after creating the page.

then if you click on a non-existing/aspiring page like [[persons/mike]] it will create the page with the contents from the template prefilled

 ![image](https://community.silverbullet.md/uploads/default/original/2X/5/56e8fa31528b190bb8aa524f90338830448bcf32.png)
