Different Templates for Different Days

Hello. Have good time!
If you have different plans for different days of the week, and you want a special template to be used when you make the Daily Note of a day, this topic is for you!
Required plugins:

  • Templater

Step 1:
Create a note and choose it for Daily Note template

Step 2:
copy and paste this code and Change it according to your need

<%*
let noteDate = tp.file.title; // assuming file title is date format like YYYY-MM-DD
let dateObj = new Date(noteDate);
let options = { weekday: 'long' };
let day = dateObj.toLocaleDateString('en-US', options);
let templateName = "";
if (["Saturday", "Sunday", "Tuesday", "Wednesday"].includes(day)) {
    templateName = "[[The name of your template file]]";
} else if (["Monday", "Thursday"].includes(day)) {
    templateName = "[[(The name of your template file]]";
} else if (day === "Friday") {
    templateName = "[[The name of your template file]]";
}
tR = await tp.file.include(templateName);
%>

Points:

  • Maybe your daily notes format needs to be YYYY-MM-DD
3 Likes

So the note containing this cool script is itself a template?

Thanks for this.

1 Like

Hello,
Thanks for this sharing.

1 Like