Page templates in v2

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:

---
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:

---
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.

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

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:

---
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.

@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 :smiley:

${"$"}{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 ā€˜$’ :wink:

I use this in my daily note template as so:

${"$"}{utils.getTodaysTasks()} 
7 Likes

And for the frontmatter I simply put the additional frontmatter after the first one :wink:

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

...
3 Likes

Nice trick!

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

4 Likes