Format placeholders work only in templates, but not new daily notes from template

Hi, I think my probem is related to this one, but not quite identical: Use new 'Templates' plugin for daily notes

I have setup a template for daily notes, and in the first H1 I would like the current date (it is in the filename as well, but I like it verbose). So I added the {{date}} placeholder. When I create an empty note and insert this template, the placeholder gets replaced by the actual date, which is what I was aiming for.

But when I create a new daily note with it’s own shortcut, the same template is used, the daily note is saved to the correct directory, but the placeholder remains and is not replaced by the date.

Is this a known bug? I once saw a thread that aimed to consolidate all templates (daily notes, zettelkasten etc) to a single plugin, but I can’t find it now. I think this would be a fantastic way to do it.

Basically I would like the ability to create a new note from a template with a user-defined hotkey, that is saved to a pre defined directory. Ideally, I wish to set multiple different hotkeys for different templates that are stored to different directories.

It would like to keep the “insert template” functionality as well, but in my use case this would be much smaller templates (like tables for example, not entire note templates).

3 Likes

In the upcoming version 0.8.10 (currently available to insiders), this feature has been added:

Daily note/Zettelkasten prefixer: Template file now accepts {{date:format}} and {{time:format}} just like the template plugin.

To be clear, you won’t be able to use {{date}} or {{time}} in the Daily Note template → you must specify the format.

2 Likes

Fantastic, I actually have 0.8.11 already. I just found the setting you mentioned.

At first I was a little confused how it worked (i literally typed {date:format} and wondered why it didn’t work). So for anyone wondering, here is a concrete example:

# {{date:YYYY-MM-DD}} Daily Note will result in # 2020-09-03 Daily Note.

Notes for people reference examples.

date: {{date:YYYY-MM-DD}} = 2020-09-22
month: {{date:YYYY-MM}} = 2020-09
day: {{date:dddd}} Tuesday

I also do things in my daily Template like this, where it creates hashtag for the month
#{{date:YYYY-MM}}
or link
[[{{date:YYYY-MM}}]]

1 Like

Are the supported date format codes documented somewhere? I’d like to use {{date:b}} (assuming b equates to %b in the standard unix date command, for instance) to get the abbreviated month name.

Syntax is from momentjs

https://publish.obsidian.md/help/Plugins/Templates

Thank you. I had searched in the Help Vault included with Obsidian, which, oddly enough, does not include the section on Templates…

The help vault and publish site should be identical. Templates is under plugins, which I understand may not be intuitive. There are updates coming to the help docs.

A fresh install of Obsidian 0.9.4 does not include Templates under plugins, whereas it DOES exist at the URL you posted above. (It doesn’t exist in the Obsidian Help directory in the filesystem either). It looks like it was somehow omitted from the .dmg build for MacOS.

Oh, my apologies then. I’m on Windows and it’s there. Like I said, changes are coming to help so I assume this will be resolved then.

No problem; the momentjs reference you provided was exactly what I was looking for. Thanks again. :slight_smile: