Trying to create a "Tomorrow" link in daily note

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I wish to plan tomorrow at the end of the day, so a link to tomorrow’s daily note in today’s would be useful. I am trying to build this.

Things I have tried

My daily note contains the following

[[<%=
tp.file.link(
tp.date.now(“YYYY/MM/DD-MMMM ddd”, 1)
)
%>]]

but this is converted into a link with the code as the target, not “2025/09/28-September Sun” as expected.

I have calendar, templater, templates, and Dailly Notes installed and active.
templater is version 2.15.2

Thanks for your help.
Ian

<% moment(tp.file.title,'YYYY-MM-DD').add(1,'days').format("YYYY-MM-DD") %>

That does produce a date, but it is the wrong date, and it is not a link.

I ran it on Sept 27, 2025, and got 2027/01/02.

How can I convert it into a link to tomorrow’s daily note?

Date format for my daily notes is “YYYY/MM/DD-MMMM ddd”

I rather suspect that both the title and format parameters need to be changed.

Today’s note has the relative path “8 History/Daily Journals/2025/09/27-September Sat.md”

You’ll need to change both formats, and because your note name doesn’t include all the date information required to construct a date (it’s missing the year), we’ll need to get that date information from the path.

[[<% moment(tp.file.path(true), '[8 History/Daily Journals]/YYYY/MM/DD-MMMM ddd.md').add(1,'days').format('[8 History/Daily Journals]/YYYY/MM/DD-MMMM ddd|DD-MMMM ddd') %>]]

Note that I also added [[ and ]] to the beginning and end to make it a link, and added |DD-MMMM ddd to add an alias, so you don’t see the full path in live preview and reading mode, just the note name.

Also note that this solution is tightly coupled to your daily note settings, if you change them, you’ll need to change your template as well. There are ways to dynamically retrieve those settings if you wish, for example:

<%*
// Retrieve daily note settings
const { folder, format } =
  app.internalPlugins.getEnabledPluginById("daily-notes").options;
// Define the format of the path to a daily note
const pathFormat = `[${folder}]/${format}`;
// Define the display text format
const aliasFormat = format.split("/").at(-1);
// Define the date based on the path of the current file
const today = moment(tp.file.path(true), pathFormat);
// Generate the link
const nextDailyNoteLink = "[[" + today.add(1, "days").format(`${pathFormat}|${aliasFormat}`) + "]]";
-%>
<% nextDailyNoteLink %>

That was very helpful - thanks.
I now have a button in the Daily Note template, that creates a daily note with the following in its button.

name Go to Tomorrow's Note
color purple
templater true
action 

// Define the display text format

// Define the date based on the path of the current file





        // it exists, jump to it. 

^button-daily-note

So I have some confusion between <%, <%* and others.
I think I want the processing to include the text from the template unchanged. Then execute it when the button is pressed. If the page does not exist, I execute the following:

// Get daily note template
<%* const tpFile = tp.file.find_tfile(“Daily Notes Template”); %>
// Create and open in Default location
<%* await tp.file.create_new(tpFile, nextDailyNotePath, true);
}
%>
Which should again, copy the instructions into the new note, without executing them, and delay execution until the button is clicked.

Hmphhh. I used to find this sort of thing easy 50 years ago., but was 24 then!!!
I guess I will simply create next Monday to Sunday, as part of Sunday’s tasks.
Regards
Ian

I have understood that I need a button in the daily note, to call a script that will do what is required.
The button contains

```button
name Go to Tomorrow's Note
color purple
templater true
action <%* ![[open-tomorrow-note|Tomorrow's note]];
%>

And the file open-tomorrow-note.js in the templates folder contains

// 9 Archives/Scripts/open-tomorrow-note.js
// ----------------------------------------
//  Open the next daily note (tomorrow) in the same tab.
//  If it does not exist, create it from the Daily Notes Template.
//
//  Current note follows pattern:
//  8 History/Daily Journals/<YYYY>/<MM>/<DD>-<MonthName> <DayOfWeek>.md
//
//  Usage: add a button to daily Note template, with
//  action <%* ![[open-tomorrow-note|Tomorrow's note]];
//    %>
// ----------------------------------------
module.exports = async (plugin) => {
  const { app, plugin: templaterPlugin } = plugin;
  const { vault, workspace } = app;
  //  Get the active file (current daily note)
  const currFile = workspace.getActiveFile();
  if (!currFile) {
    new Notice("No active file – button pressed outside a note.");
    return;
  }
  // Extract the date from the current file’s path
  const path = currFile.path;
  const dateRegex = /\/(\d{4})\/(\d{2})\/(\d{2})-/;   // captures YYYY, MM, DD
  const match = path.match(dateRegex);
  if (!match) {
    new Notice("Could not parse date from current file path.");
    return;
  }
  const [ matched,  currYear, currMonth, currDay ] = match;
  const currDate = dayjs(`${currYear}-${currMonth}-${currDay}`, "YYYY-MM-DD");
  if (!currDate.isValid()) {
    new Notice("Parsed date is invalid.");
    return;
  }
  // Compute "tomorrow"'s date
  const tomorrow = currDate.add(1, "day");
  // example path: 8 History/Daily Journals/2025/10/01-October Wed.md
  const fileName = tomorrow.format("YYYY"/"MM"/"DD-MMMM ddd")+".md";
  const dirPath  = `8 History/Daily Journals`;
  const fullPath = `${dirPath}/${fileName}`;
  //  Open the note if it exists – otherwise create it
  const existingFile = vault.getAbstractFileByPath(fullPath);
  if (!existingFile) {
    // File does not exist – create it from the template
    const templatePath   = "9 Archives/Templates/Daily Notes Template.md";
    const templateBody   = await templaterPlugin.templater.file.read(templatePath);
    // Create the file
    await vault.create(fullPath, templateBody);
  }
  workspace.openLinkText(fullPath, "", true);  // open it
}

However when I click the button, I get an error. The console contains

plugin:buttons:2291 Error processing templater in button: Error: Template syntax error: Invalid or unexpected token
    at Ws.n.wbg.__wbg_new_8d2af00bc1e329ee (plugin:templater-obsidian:18:4397)
    at 00032406:0x9ba2
    at 00032406:0x8d55
    at on.render_content (plugin:templater-obsidian:18:3041)
    at bi.parse_commands (plugin:templater-obsidian:18:74295)
    at eval (plugin:buttons:1441:38)
    at clickHandler (plugin:buttons:2281:35)
clickHandler @ plugin:buttons:2291
await in clickHandler
eval @ plugin:buttons:2258
s @ enhance.js:1

This does not point me to an error in my code :frowning:

Can someone please point out what I am doing wrong?
Thanks
Ian

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.