Templater Script - Ask for Note Title

Source

I found this on Reddit but cannot find the OP anymore – if it's you, or you know who it is, kindly let me know, and I will happily give credit where credit is due.

Setup

For this to work, we need to create a new template in our designated templates folder. For example, Template - Dummy. Then we need to copy/paste the templater code into it.

Result

If you have a hotkey for creating a new note from a template (in my case, that's ALT + N), then Obsidian will ask for the template. Choose the Template - Dummy and you will be prompted for a title before the note is created.

Alternatively, you can create a new note and then insert the Template - Dummy template. If you do that, you will have to run the templater script manually – for me, this is the hotkey ALT + R. The end result is the same.

Code

<%*
  let title = tp.file.title
  if (title.startsWith("Untitled")) {
	title = await tp.system.prompt("Title");
	await tp.file.rename(title);
  } 
  
  tR += "---"
%>
tags: 
---
# Templater Script - Ask for Note Title

<% tp.file.cursor(1) %>