New User - Expected Workflow for Creating New Notes with Templates?

I’m new to Obsidian and just started looking into using Templater to create some structured notes (like an inventory of computer games, subscriptions, tech devices, etc.).

I’m a little confused on how people actually create notes when using templates/templater:

  1. I create a folder, then a template, then add the “Folder/Template” pair to the templater settings (e.g., a Games folder, a Computer Game template).
  2. If I right-click on the “Games” folder name in the folder view and select “New Note”, the note is created and the “Computer Game” template applied.
  3. However, the new note has the name “Untitled”.

What I’m trying to do

I am using suggester to capture information about the item (game, in this case). I don’t want to have to ask for the name twice, but I would like the note to include the name of the game and have the name of the game in the note as meta data.

Things I have tried

I tried:

  1. Creating the name (via suggester), in the frontmatter and then using rename at the end of the note to rename to frontmatter:
- Title:: <%await tp.system.prompt( "Game Title?" )%>
.
.
.
<% tp.file.rename(tp.date.now("YYYYMMDDHHMM ") + tp.frontmatter.title) %>

But that doesn’t work as the tp.frontmatter.title at the end of the note is “undefined”.

  1. I’ve also tried the opposite, using suggester at the beginning of the note template and then using either tp.file.title or {{title}} later in the note, but both are “Untitled” even though the note (file) name is now changed.

I think that setting the name of a note to a value that was set via templater’s “suggester” and also having that name in the note itself would be be a pretty common thing.

So I’m wondering if maybe I’m overthinking this and there is a better way or different workflow to accomplish this goal of using different templates for different note types and be able to set the note title and a note’s metadata to a “suggester” result without having to ask for the same data twice.

Any help would be appreciated.

Thanks!
phlepper

Note: Templates (Obsidian Core) and the Templater (community plugin) use different syntax that can’t be mixed and matched.

They should have different folders to store the templates (for your sanity), so create, e.g., Templates-core and Templater folders. Templates with the {{date}} syntax go in Templates-core; Templater templates with the <% syntax go in the Templater folder. Yes, the naming isn’t ideal and confusing at first :cold_sweat:

Once you’ve made your Templates and Templater templates and set the folders accordingly in settings, you don’t need to interact with those folders again unless you want to adjust the templates. (I keep these folders in a “meta” area along with my folder for attachments and other Obsidian related stuff).

In a new note → run the Templates/Templater command → choose the template from the correct modal list → the template will be applied or with Templater it may prompt you for input depending on what you’ve written in the template.

Have a look at these two posts below:

Thanks @ariehen! I am not actually combining the two syntaxes in my templates, just provided the {{title}} example as it was something I tried.

I think your second linked article was more helpful for my problem and leads me to think that the best workflow for using templates (with templater) would be to:

  1. Create a new note and name it with my title like so “YYYYMMMDDHHMM My Title” (I use the Unique Note Creator).
  2. Use templater’s “Open Insert Template Modal” (Alt-E) which will insert and apply the template.
  3. Have the template extract the My Title from note’s title and use it to set Meta data in the note.
  4. Also have the template rename / move the new note to the appropriate folder for notes of that type.

Is this what most people are doing?

Note this also solves one of my other problems where “My Title” might include characters that are invalid in a note name and so the rename fails due to suggester prompting for the title versus naming the note with the title after the date.

Thanks!

Great! I wasn’t sure how familiar you were with either Templates or Templater, so linked both examples. I 95% use Templater, but the core Templates, while not as powerful, has its uses.

I have a few templates that do about the same steps, but it really depends on what needs doing at the time and what I’m working on. As it’s been said numerous times: ask ten Obsidian users for workflow advice and you’ll get fifteen plus answers. :joy: I’d say just try stuff out and you can (and will) adjust things over time.

Even though Templater is capable of reading stuff out of the frontmatter, it’s not capable of setting it and reading it at the same time. But fear not, you don’t need to do it that way, and the version below show how this is commonly done using a pre-amble where you ask for information, and then re-use that information later on.

<%* 
const title = await tp.system.prompt( "Game Title?" )

await tp.file.rename( tp.date.now("YYYYMMDDHHMM " + title) )
_%>
---
title: <% title %>
date: <% tp.date.now("YYYY-MM-DD") %>
---

This example asks for the title, uses that to rename the file accordingly, and then proceeds to add a frontmatter with a title (as entered), and a date field with a proper date format, so that if you want to query this file using Dataview it’ll have an actual date (readily available in file.day, instead of the “random” number in the file title.

Alternatively, you could use the ISO8601 date format in the title, with something like tp.date.now("YYYY-MM-DD[T]HH:mm") + title ), but not everyone like that format (although it’s the format which is most reliable in other contexts).

Note that in the example I’m renaming the file at the start within the pre-amble, so that I’m done with it early on. This ensures it gets the rename, and leaves the rest of the template cleaner and more to the point of the actual content of the resulting note.

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