Templater: What should I do for solve this problem?

What I’m trying to do

I’m just learning Obsidian. I copied the ready-made code from a template and pasted it into my Notepad file, but some parts of the code don’t work properly when it’s in view mode (  let title = tp.file.title ) and the lower part (Weeks of the Month) displays correctly. What should I do?

Things I have tried

So this looks like a Templater snippet and I don’t know where the  characters come from but they shouldn’t be there :sweat_smile:

You could try to use this instead:
(note that it’s untested :innocent: )

<%*
let title = tp.file.title;
if (title.startsWith("Untitled")) {
	title = await tp.system.prompt("Title");
	await tp.file.rename(title);
}
_%>

# <% title %>

The template will need to be run by Templater for it to do what you’re asking it to do (either get the title of the note if it’s not Untitled or rename it and then add it as a header at the top of the note…

1 Like