I’d like to populate Title when assigning a template to a new note. I’m reaching for the inverse of {{title}} in Templates plugin. Instead of inserting Title into the note, I want to populate Title from the text in the template.
What motivates this desire: I use Title prefixes to declare the type of note. For example, my notes related to companies all have a Title that begins with ‘Company -’
Things I have tried
I’ve read the documentation for Templates, Templater, Notes Composer, and Dataview plugins hoping that one of these would support my desire, but I don’t see how they will.
I’m not sure I fully understand the question, but using Templater, you can apply the template after you create the note, then apply a template like this:
<% tp.file.path() %>
You can even have templater insert custom content (e.g. frontmatter perhaps) based on the file name. Like this (used from @tallguyjenks sample vault). This uses the first character of the file to determine the template to include, but could easily be changed to use the first word (for example) in the filename.
The example Company-Note template for Templater below is based on one I found when I first discovered Obsidian (I cannot re-find the original source to give appropriate credit).
---
<%*
let title = tp.file.title;
if (title.startsWith('Untitled')) {
title = await tp.system.prompt('Company - ');
await tp.file.rename(`${title}`);
}
-%>
title: <%* tR += `${title}` %>
created: <% tp.date.now('YYYY-MM-DD') %>
kind: company
---
# <%* tr += `${title}` %>
<% tp.file.cursor() %>
The important thing is that it changes the note’s title using the tp.file.rename function if it has not previously been entitled.
Thanks. This looks like what I want to achieve and the user interface behaves as I would expect (prompting me for the template to apply and then asking me for the company name).
Alas, I get a “Templater Error: Template parsing error, aborting. Check console for more information”
From the Console I see “tr is not defined”
As a non-developer, I’m in over my head, but I’ll dig into this some more to learn as soon as I can free some time.
Thanks again.