How to make title from template

I can create tags and other meta with template, but what about the title of the page?
I want to create template that the title is some word + the date.
I tried this but the title keep showing “untitled”
any way to do this?

If you install the Templater community plugin, you could use the following in a template:

<% await tp.file.rename("Some Word"+ tp.date.now("YYYY-MM-DD HHmmss"))%>

Remember to remove any surrounding backticks that may be there if you copy and paste the code. Also, remember that you should use the “Templater: create new note from template” command. Feel free to remove the HHmmss. I only added it in case you wanted the time as well. This might be useful for days where you want to create more than one file with this template.

Hope this helps some. Good luck!

1 Like

You can use {{date}} in your template. The default date format for this is YYYY-MM-DD, but you can change that, see here: Templates - Obsidian Help.

Where should I put that line ?

1 Like

This is working in the body but not for the title.

In a note in a folder for templates. Then go in to Templater settings and designate that folder. This way, when you run the Templater: create new note from template command (alt n hotkey), you will see a list of just the notes in that folder to choose from. At that point, just pick the note you placed the line in. And obviously feel free to populate the template with other stuff. Good luck!

Do you perhaps have the Filename Heading Sync plugin enabled? At first, I also couldn’t make it work (the note title stayed ‘Untitled’ no matter what was in the template, like you described) until I ignored the current file from this synchronization (search for ‘Ignore current file’ in the command palette) and reapplied the template.

It’s not working for me, even the {{date}} in tags are not generated.

Sorry to hear that. I tested it and it worked for me. Could you show what you tried? It would make it easier to help.

Thanks.

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