I have triggered recursive script, yet "Trigger templater upon new file creation" is off

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

Create a button in my daily note template, that will open “tomorrow”'s daily note, creating it if necessary.

Things I have tried

The button contains:

    templater true
    action <%* await tp.user.themorrow(tp) %>

I have tried with and without the *.

The script contains:

const junk = tp.file.create_new(template, newTitle , true , newDir );
return

Which is only executed if the next page does NOT exist.
I have tried every option before the tp.file
I have also removed the return, and used false. so it drops through to the open existing page command.
It produces one of two results: either
a) The script fails to load, giving me no information about where the error is. Or
b) The script is called for the new page, and again for the next day after that, and the next day after that, and continues until the machine is rebooted.

The script has create daily notes all the way until 2055! What a mess.

Note - my daily notes have the structure “8 History/Daily Journals/2025/10/01-October Wed.md”
i.e. location+“/”+tomorrow.format(“YYYY/MM/DD-MMMM ddd”)+“.md”;

Also, as noted in the title. “Trigger templater upon new file creation” is off.

How can I fix this?
Thanks
Ian

Hi Ian,

Here’s what I think is happening from what you shared.

Your button runs a Templater script, and that script calls:

tp.file.create_new(template, newTitle , true , newDir );

create_new renders the template you pass in. If that template contains any Templater execution ( for example, another <%* await tp.user.themorrow(tp) %>), the new file immediately runs the same script again until you stop it.

Reload Obsidian should stop this, Ctrl + R used to be the default, but newer versions you may have to rebind this.

Without seeing your full script, I can’t really adjust anything for you, but I would recommend adding a guard into it, that sets a const relPath = 'path/to/your/note.md` and then you’re already inside of the file you created, just exit.

  if (tp.file?.path === relPath) return;

You would want to add this before your script created the new file. This should keep it from running templater, if its running inside of the file it created.

If you’re comfortable, I would recommend posting your full script and someone way smarter at templater than me could come along and clean it up for you.