Templater: Wait for Title until Note is Named

Things I have tried

<%* let title = tp.file.title

if (title.startsWith(“Untitled”))

{title = await tp.system.prompt(“Title”);

await tp.file.rename(${title});} tR += “—”


# <% tR += ${title} %>*

which I found in this forum, but it doesn’t work for me… any ideas?

What I’m trying to do

When I have tp.file.title elemts in my page then they are all “Untitles” by default, when I create a new note, because initially that’s the title, makes sense, but when I rename the page it doesn’t change. I want to be able to have the titles in my templates change when I change the title so that I don’t have to retype it everytime where instead of the title there is an “Untitled”.

You could try the Obsidian Filename Heading Sync Plugin. There might even be another plugin that also does this, but I’m not sure. Here’s a link to a post that is very relevant and that links to the GitHub page: Plugin for keeping the filename and first heading of a file in sync

Good luck!

There appears to be an issue with that Templater script: https://github.com/SilentVoid13/Templater/issues/636#issue-1231624729

I’m not sure it is resolved yet, but the plugin may otherwise work fine. I hope you can get it working.

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