# Page templates in v2

**URL:** <https://community.silverbullet.md/t/page-templates-in-v2/2037>\
**Category:** Troubleshooting\
**Created:** [March 25, 2025, 6:14pm UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037 "2025-03-25T18:14:21Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![nate34k](https://community.silverbullet.md/user_avatar/community.silverbullet.md/nate34k/32/1241_2.png) [@nate34k](https://community.silverbullet.md/u/nate34k)\
**Post date:** [April 18, 2025, 3:06am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/21 "2025-04-18T03:06:39Z")

</div>

Sounds good. I figured out a nice way to do it.

Follow up question. Is there a way to retain the query in a page template? When I make a new page from this template:

```auto
---
command: "Journal: Daily Note"
suggestedName: "Journal/Daily/${date.today()}"
confirmName: false
frontmatter: "
  parentWeek: Journal/Weekly/${date.year()}-W${date.weekNumber()}\n\
  yesterday: Journal/Daily/${date.yesterday()}
"
openIfExists: true
tags: meta/template/page
---
|^|
${query[[
  from p = index.tag "page"
  select {
    name = p.name,
    modified = p.lastModified
  }
  limit 3
]]}

```

Its output is:

```auto
---
parentWeek: Journal/Weekly/2025-W16
yesterday: Journal/Daily/2025-04-16
---

{{name = CONFIG, modified = 2025-04-17T13:48:50.151}, {name = Functions/Date, modified = 2025-04-17T16:40:54.778}, {name = Journal/Daily Note, modified = 2025-04-17T18:00:33.149}}

```

Ideally I was hoping for a way to be able to use the page template to put a query in the page created by the template, not have it be evaluated.

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [April 18, 2025, 7:41am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/22 "2025-04-18T07:41:41Z")

</div>

No not yet, I need to figure out how to “escape” Lua directives. Haven’t gotten to that yet. Let me create an issue: [Ability to escape Lua expression directives · Issue #1343 · silverbulletmd/silverbullet · GitHub](https://github.com/silverbulletmd/silverbullet/issues/1343)

---

<div class="post-metadata">

**Author:** ![vxnick](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vxnick](https://community.silverbullet.md/u/vxnick)\
**Post date:** [April 18, 2025, 8:37am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/23 "2025-04-18T08:37:53Z")

</div>

A potential workaround that I use (but has its own problems, described below) is to embed pages containing Lua on my daily journal template.

For example:

```auto
---
suggestedName: "Journal/${date.today()}"
confirmName: false
openIfExists: true
tags: meta/template/page
---
# Inbox
![[Library/Personal/Embeds/Inbox]]

# Notes
- |^|

# Tasks

## Incomplete
![[Library/Personal/Embeds/IncompleteTasks]]

```

This works except within the PWA (which I don’t use, but tried after spotting it in my browser) and previously on edge/v1 when I was in online mode - in terms of the embeds not being evaluated, I mean.

---

<div class="post-metadata">

**Author:** ![marad](https://community.silverbullet.md/user_avatar/community.silverbullet.md/marad/32/1179_2.png) [@marad](https://community.silverbullet.md/u/marad)\
**Post date:** [April 29, 2025, 10:58am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/24 "2025-04-29T10:58:03Z")

</div>

@zef @nate34k

> No not yet, I need to figure out how to “escape” Lua directives.

This is actually pretty easy to do currently! You just need to play the “meta-game” on the higher level 😃

```lua
${"$"}{date.today()}

```

This `${"$"}` will execute while templating effectively putting it inside the rendered text. The rest is simple text that magically turns into inline query by addition of the missing ‘$’ 😉

I use this in my daily note template as so:

```lua
${"$"}{utils.getTodaysTasks()} 

```

---

<div class="post-metadata">

**Author:** ![marad](https://community.silverbullet.md/user_avatar/community.silverbullet.md/marad/32/1179_2.png) [@marad](https://community.silverbullet.md/u/marad)\
**Post date:** [April 29, 2025, 11:02am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/25 "2025-04-29T11:02:50Z")

</div>

And for the frontmatter I simply put the additional frontmatter after the first one 😉

```markdown
---
tags: meta/template
description: this is the meta page frontmatter
---
---
description: this will be the frontmatter of the new note
---

...
```

---

<div class="post-metadata">

**Author:** ![mjf](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mjf/32/654_2.png) [@mjf](https://community.silverbullet.md/u/mjf)\
**Post date:** [April 29, 2025, 11:27am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/26 "2025-04-29T11:27:35Z")

</div>

Nice trick!

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [April 29, 2025, 8:07pm UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/27 "2025-04-29T20:07:34Z")

</div>

Well obviously that’s how to do it. Do I need to spell everything out? 🤣

---

<div class="post-metadata">

**Author:** ![urnlahzer](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/u/ecc23a/32.png) [@urnlahzer](https://community.silverbullet.md/u/urnlahzer)\
**Post date:** [August 20, 2025, 8:07am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/28 "2025-08-20T08:07:19Z")

</div>

I’ve been trying to do this exact thing, but I’m struggling to get it to work. Would you be willing to share your code?

---

<div class="post-metadata">

**Author:** ![Matt](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@Matt](https://community.silverbullet.md/u/Matt)\
**Post date:** [September 9, 2025, 5:27pm UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/29 "2025-09-09T17:27:39Z")

</div>

Hey @vxnick , thanks for sharing the daily journal template, would you mind sharing your Embeds from above (Inbox and IncompleteTasks)? TIA!

---

<div class="post-metadata">

**Author:** ![cmdrSpectral](https://community.silverbullet.md/user_avatar/community.silverbullet.md/cmdrspectral/32/525_2.png) [@cmdrSpectral](https://community.silverbullet.md/u/cmdrSpectral)\
**Post date:** [September 29, 2025, 5:15am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/30 "2025-09-29T05:15:48Z")

</div>

Hey,  
How can I replicate the “forPrefix” template behaviour of v1?  
My use case is quite simple:

- I have daily and weekly journaling
- I have next/prev buttons which go to the proper daily/weekly note

The moment the page does not exist - templating is not triggered. “forPrefix” did the trick as it autoapplied the templates based on location. - I found some solve here - but I was wondering if it’ still that hacky? → [Recreate the forPrefix hook in page templates - #7 by roberth](https://community.silverbullet.md/t/recreate-the-forprefix-hook-in-page-templates/2351/7)

And a second bonus question - is there a way to have “#tags” at the start of the template. They always seem to be removed when template is evaluated - bug or feature? (I have to add them in the frontmatter to have tags in my templated pages)

---

<div class="post-metadata">

**Author:** ![crgo1978](https://community.silverbullet.md/user_avatar/community.silverbullet.md/crgo1978/32/3037_2.png) [@crgo1978](https://community.silverbullet.md/u/crgo1978)\
**Post date:** [February 4, 2026, 6:16pm UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/31 "2026-02-04T18:16:02Z")

</div>

How do I implement the templates on the index ? Do I paste it on it. Or do I have to enclose it?

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [February 4, 2026, 6:18pm UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/32 "2026-02-04T18:18:40Z")

</div>

Have a look at [Page Template](https://silverbullet.md/Page%20Template) for better, more up to date documentation

---

<div class="post-metadata">

**Author:** ![crgo1978](https://community.silverbullet.md/user_avatar/community.silverbullet.md/crgo1978/32/3037_2.png) [@crgo1978](https://community.silverbullet.md/u/crgo1978)\
**Post date:** [February 7, 2026, 4:42am UTC](https://community.silverbullet.md/t/page-templates-in-v2/2037/33 "2026-02-07T04:42:07Z")

</div>

Thanks for the reply! I'll check it out!

[Previous page](https://community.silverbullet.md/t/page-templates-in-v2/2037.md?page=1)
