Note title automatically generated from first words of the Note (similar to Joplin)

Use case or problem

I create dozens of new notes a week and they’d all be named Untitled {number} if I didn’t specifically click the title bar and name them.

Proposed solution

I’d like the first 5-7 words of the note to auto-populate to the note title. This would often correspond to the top-level header of the note anyway.

For instance if I create a note that starts with the header

# Dishwasher Repair Tips

the note would just be automatically titled Dishwasher Repair Tips unless I change it, rather than Untitled.

I’m curious if there’s a CSS solution to this.

I realize this may run into problems with filename rules. Perhaps the auto-population could remove illegal filename characters.

Current workaround (optional)

No workarounds, just manual entry.

Related feature requests (optional)

1 Like

You can accomplish this with the Templater plugin.

I have turned on the option to allow Templater to trigger on new file creation. My new notes use the following template:

  let title = tp.file.title
  if (title.startsWith("Untitled")) {
    title = await tp.system.prompt("Title");
    await tp.file.rename(`${title}`);
  tR += "---"
tags: Note <%tp.file.creation_date("YYYY")%>
# <%* tR += `${title}` %>

<% tp.file.cursor() %>


## References:

creation date:: [[<%tp.file.creation_date("YYYY-MM-DD")%>]] <%tp.file.creation_date("HH:mm")%>

The script in the template asks for a name if the note is untitled and then renames the note with the title and puts it in a header at the top of the note.

This script is not my concoction. I modified one that I found elsewhere–but I forget where.

I hope it helps!


Oh cool! Thanks I’ll try this out. I haven’t used Templater so this looks like a good introduction.

In some cases, I’m copy and pasting into a note. I wonder if there’s a way to take the first few words from the pasted text. I guess it’s probably not possible, since it would have to wait for the first text to show up. (Not sure how Joplin does it.)

However this plugin will save me a lot of time with 80% of my notes. Thanks!

1 Like

I wonder if you could take a moment to explain where you’re supposed to put this code? Is this a ‘startup template’, or a ‘folder template’? Or is it a ‘user script function’? I have no idea how to add this to a ‘template’, or even how to make a template.

---- Aside:

The fact that Obsidian doesn’t automatically generate a title from the first line of the note is a deal-breaker for me. I save dozens of articles per day and do not have time to copy and paste every first line into the title.

Apple Notes does this automatically. I’d rather suffer with Apple Notes’ lame search than have to copy and paste every article title for everything saved to Obsidian. It’s beyond words out ridiculous it is, in my opinion. Haha.

If you are saving on a desktop or laptop, consider using the Markdownload browser add-on to save those articles (search for that add-on in this forum for more info). It will convert the html article to markdown and use the title as the file name.

1 Like