Daily note template with tomorrow and yesterday links and annual folders

I spent a couple hours working on this this morning so I thought I would share in case anyone else is trying to get a daily note template set up with annual subfolders.
This uses the core Daily Notes plugin as well as using/working with community plugins Templater and Calendar (that is, clicking a date in calendar creates a new daily note in the correct annual subfolder, even if not already created, with correct yesterday and tomorrow notes). Also populates the day of the week and the full spelled out date in the header.

← [[Daily/<% tp.date.now("YYYY/MM-DD", -1,  (tp.file.folder() + "/" + tp.file.title), "YYYY/MM-DD") %> | <% tp.date.now("MM-DD", -1,  tp.file.title, "MM-DD") %>]] | <% tp.file.title %> | [[Daily/<% tp.date.now("YYYY/MM-DD", 1, (tp.file.folder() + "/" + tp.file.title), "YYYY/MM-DD") %> | <% tp.date.now("MM-DD", 1, tp.file.title, "MM-DD") %>]] →

# <% tp.date.now("dddd, MMMM D YYYY", 0,  (tp.file.folder() + "/" + tp.file.title), "YYYY/MM-DD") %> 

Creates a daily note header like this (edit mode):

or preview mode:

You could cut down on the breadcrumb code by using words like “yesterday” and “tomorrow” or “previous” and “next” but I prefer to have the dates linked so I made the code print those, too.


Nice. And for anyone looking, theres more discussion here

1 Like

Dumb question @coppereye:
I copied the code above at the beginning of my template (the one used by the Daily Note Plugin) but once the note is created the code is stil there as code: i.e., nothing is created
What am I doing wrong?

I think it’s because you need to use the Templater plugin for this to work. :blush:

Yes I’m using Templater and apparently this other code (I found in another post) works:

### [[<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>|⬅]] <% tp.file.title %> [[<% tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD") %>|➡]] # <% tp.date.now("dddd, MMMM Do, YYYY", 0, tp.file.title, "YYYY-MM-DD") %>

while with this one i get a date format error…
thanks anyway!


I think the default curly-brackets built-in templating date engine might have been updated to be smart enough to do this without Templatr? But I’m too new to be sure.

I’m still not getting a proper output when using either of the scripts. I will come back after more research.

1 Like

Sorry I missed the replies here, wasn’t getting any notifications about them. The only reason I can think you might have a problem with the date format is due to not setting up the format on Daily Notes to match? My daily notes format is YYYY/MM-DD. I copied the code straight from my template so if that’s not the issue I’m not sure what else could cause it.

Same problem here. Did you solve this issue?
I find out that when I create a note using Templater command ''Templater: Create new note from template", this problem does not occur.
However, only when I create a new daily note by clicking the date in Calendar, it happens.
I think mainly reason for this is that Calendar uses core plugin Template, not Templater.
But even though I can guess the cause for this, I cannot find a way to fix it :frowning:

@nestorito @IDeezel
I just figured it out! Toggle the following option in Templater settings.

If you want to use this feature for calendar, you can directly use the following commands:

{{date-1d:YYYY-MM-DD}} // yesterday
{{date+2d:YYYY-MM-DD}} // in two days
{{date+1M:YYYY-MM-DD}} // next month
{{date+10y:YYYY-MM-DD}} // in 10 years
{{date +7d}} // use default format

ref: [FEAT] Add support for "math" in templates by liamcain · Pull Request #166 · liamcain/obsidian-calendar-plugin · GitHub

1 Like