Using the Obsidian Templater Plugin

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- The Obsidian Gems of the Year is a list of the best of the best from the Obsidian community rather than its core developers. And in 2021, the plugin that won second place in the plugins category is called Templater by SilentVoid. Templater has changed the way that I take notes and that's by capitalizing on something that we wouldn't typically associate with note taking-- automation. In this video, I'm gonna talk about what Templater is and how I use it to take meeting notes, maintain a database of people that I know and even play tabletop role-playing games like D&D. Templater is a community plugin that allows you to define a structure or a format that you can then apply to your other notes so you're not doing the same thing each time. Don't get confused, though, with Templates and Templater. Templates is a core plugin that ships with Obsidian that you don't have to download, but you do have to enable it if you use it. And Templater is a community plugin that you do have to download and enable. In this video, I'm gonna talk about Templater in particular, but in general, the difference between the two is one of complexity. Templates is more like a copy paste, so you define the structure and then you paste it, kind of, into a note. And the only things that are dynamic about that are gonna be like the date or the time or the title, so very limited amount of things that you can change on the fly. Other than that, it's mostly a direct copy and paste. Templater though is way different because you can programmatically change almost anything. So you could have Templater put different things in your notes, depending on certain conditions, like what day of the week it is or what folder the note is in. This will make a little bit more sense when we get to the specific use cases, so let's get right into that. I see three main use cases for using Templater and you can use any or all of them depending on what you're trying to do. The first is using single line templates. The second is applying entire templates according to certain conditions. And the third one is using your own user scripts. First, let's talk about using single line templates. I'm going to create a new note here. I'm hitting Command + O just to go to the Quick Switcher and I'm going to call it Test Note. This is an entirely new note, so I'm going to have a heading called Test Note. And every template using Templater starts and ends with the same format. It is the left arrow and then percentage and then it ends with percentage then the right arrow. And in between them is where you put the instructions for what to replace this entire line with. One of the most common things that I use this for is TP, that means Templater, file and then the title. This is kind of equivalent to the Templates syntax. Templates, the core plugin uses the two brackets opening and closing and then title. So this might be simpler, but Templater has more of those, which is why it's a little bit more complex. When I apply the template using Templater, this entire line should then be replaced with this title. So let's see how this actually gets replaced. Hit Command + P or Control + P if you're on Windows to open up the Command Palette and then start typing replace templates and select Templater, replace templates in the active file. You'll notice that I've also added a hotkey to it so that I can do this on the fly. I'm on a Mac, so I'm using CTRL OPTION R but you can change it to whatever you'd like. In this case, I'm just going to click on it to run it. And you can see that this, where the template used to be now you see the title, which is Test Note. If we go back a step and have the full template here, I'm going to add to that, this time I'm going to put in the date as well. Date now and then I'm going to specify the format for it, which I want to be YYYY-MM-DD, all in numbers. I'm going to end the template. But another single line template that I use in my templates is the one that retrieves the value for a parameter I've set in the frontmatter. So let's say we have the frontmatter here and let's say that I've got type, and this is a meeting. As the single line template, I'm going to put in tp.frontmatter and you'll notice that as I'm typing, there are these options here. This is also a cool way to explore. These are all the default variables that Templater has already set up so you just have to select them and use them rather than creating your own. In this case, I want frontmatter and then I type in the name of the parameter, which in this case is type. Then I'm going to end this one and this time I'm going to hit the hotkey rather than going through the command pallet. But I'm still just replacing the templates in the active file. Now I've got, as expected, the title, the date and also the value of the type here. So that's how you would use Templater to replace those strings with metadata from the file in question. But typically, you would build from this and put it in a template. So let me show you that. Instead of this, I'm going to create a meeting template. Let me delete this file and let me show you that I've got a templates folder here and I have a meeting note within that templates folder. In this meeting note, I have everything that I want to appear in a meeting. Once I've decided that I'm taking notes on a meeting, I want this metadata in there. So you can see here that I'm using that tp.date null format and also the title. Now you'll notice that the title is within these brackets and I could have it without that. It is the value inside that's going to be replaced with the title of the meeting. But having them within the brackets turns it into a link. The reason that I like to do that, and this is optional is that I found that if I just type out the heading then if I change the name of that file, then the name of the file and the heading title no longer match and I don't like that. So I've just defined it as a link too. Then I have a bunch of sections here that I expect myself to fill out and I would type out the actual meeting notes here. And aside from the meeting template, I also have created a person template. So I create a note on people that I speak to, especially those that I have meetings with and I want this template applied whenever I create a new person note. Within the person note, we've got some metadata still and I'm using the same trick here to create a link as the heading. So this is a little bit different from the one that I showed you. It is still a single line, but instead of just pulling out a value for, in this case, the title, I'm also saying that I want this entire note to be moved into the people folder so that if I make a note for a person and it's not in the people folder yet, and then I apply the template for a person, not only will it apply that template, but it'll also automatically move that note to the people folder. And then under meetings here, I do have a data view query that has a template inside it. This is just going to bring up all of the meetings that I have with this person automatically. So now I've got a template but I haven't yet specified when exactly this template should be applied. So for that, I'm going to go into the settings for Templater and I'm going to specify that template's folder so that Obsidian knows that all of my templates are gonna be stored there. I'm also going to click enable on trigger Templater on new file creation. What that is doing is giving Templater the permission to replace any templates in new files that are created. In this section, folder templates you can specify default templates that are applied to every note that are created in different folders. Since I already have a meeting template, I'm going to choose the folder meetings because I put all my meetings there and I'm going to choose the meeting template in the templates folder. And then I'm going to add the same thing, but for the person template. So now all of the people that I have notes on are in the people folder and the name of the template that I want applied is person. So I'm going to add both of those. We'll exit out of that. To start with, I would hit Command + O, that's the quick switcher again. And let's say I want a new meeting, meeting today. I'm going to hit Enter and that creates that. And as you can see, the meeting template was automatically applied, it already took the date. It has the file name as a link in the heading, but I don't have any attendees yet. Let's say I have a meeting with Jonathan Archer. Since this is a person I'm going to say people and then a slash, that means I wanna put it in the people folder and then I'm going to type out his name, Jonathan Archer. I don't have a page for this yet but I'm going to create it right now. We should see a new note for Jonathan Archer that follows the person template. So I'm holding down Command here and I'm gonna click on it so that it opens up in a new pane. And that looks like it's been created. These are the ones that were specifically for people. The data view query has also been updated so that now it says Jonathan Archer, instead of the template that was there. So I've already shown two use cases, one is how to use those single line templates and then the second one was using those single line templates as building blocks to create a bigger template that is automatically applied when you create a note in a specific folder. Now the third use case is a little bit more complex, but I wanted to include it as an example of how you can do very complex things and distill them down to a few button clicks just by using Templates and other plugins. This use case hinges on the fact that Templater allows you to create user functions, which means that if you can write JavaScript or copy code from somebody else then Templater can actually run those. What that means is that you can make your templates a lot more dynamic. Now this is going to be my TTRPG workflow that I'm demonstrating here, but it is using quite a few scripts that I've written and also quite a few plugins. Specifically, I'm using Templater but also Buttons, QuickAdd, Callouts, Fantasy Calendar and Dataview. So definitely not something that's for everybody, but I just think this is a cool way to show you of how deep you can get into Templater. So my TTRPG workflow starts with the games index, which is a list of all of the campaigns that I'm currently running or playing in. To create a new game, I'd click on Add New World here and let's say that this is a demo world. And you'll see that there's another page that's been created. This is using a specific world template and that the data view query on the games index has been updated to include that demo world. Now I could put in the system here for example and have that be updated in the data view query. Let me exit out of this games index. And within the world, I can have a list of sessions, except I don't have any sessions for this world right now. So let me add one right now. So I'm gonna click that and now it's added a session according to, you've probably guessed, a session template. Now this session has pulled in a whole bunch of parameters. It's pulled in the fact that it's a session. It's taken the campaign and world from the World page. It's counted the number of sessions that I currently have and it increments them automatically. So this is the first, so it's named it like that as well. So it starts with 001 and then an underscore and then today's date. I do use the plugin Obsidian Fantasy Calendar for many of my games. I haven't set it up for this one, but if I did, I would name it the same as the world and it would automatically populate what today's date is or today in game. Scrolling down to this session here, I'm also using Callouts to have a little session summary page. Now this is saying no games were found because this is the recap section and there were no previous games. But we'll look at what that looks like in a second. So I would put the log in here, lots of stuff happened. And then at the end of the session, I would typically put in a longer summary in this part. And there's also a one liner here in case I just want a quick overview of the main things that happened in this section. So let me put the adventure begins just to see that that summary has been updated in the date view query in the world as well. Now I'm going to exit out of this, go back to the World page and let's say I have another session. So when we click Add Session again and now it's automatically incremented to the second session for this game. And by the way, all of these things are being created in the TTRPG's folder within that folder for the world. I do this because sometimes I play in the same system or the same published worlds, so I want to keep every campaign and every group separate. Within that demo world, I have the sessions here and the World page. Let me exit out of this World page and look at this second session more closely. It's very similar to the first one, except that now it's automatically pulling in the session summary of the first session within the recap. Now what if in this session we meet somebody? We met in a tavern and met the bartender. Let's say that that is an NPC, again, I'm going to hit Command and then click on it to open that note up in a different pane. Now because this is a note that is neither a session nor a world note, Templater has automatically applied my TTRPG frontmatter template. Then I would go in and say that this one is an NPC and maybe I met this person in the tavern called the Crossed Pikes. If you're curious about how I set this up, I'm basically using a few templates. This is the TTRPG frontmatter one for adding in NPCs or locations. This is my world template. I have two session templates depending on whether I'm a GM or a player. The GM one has some more sections in it that have secrets that characters might discover, loot and so on. But it works on pretty much the same principles with the same templates here that get pre-populated. You might have noticed that some of these templates have tp.user, those are the user scripts that I've created. So in Templater, when you go through the settings here and scroll the way down, you can have a section where you specify what folder you're putting your scripts in. Now these are all JavaScripts. So it looks like it's detecting seven of mine. Create world session, get campaign list, Now these are very specific to me. But let me show you what that looks like. This is what one of those scripts looks like in my IDE, which is VS code. The vault that I've been using is a test vault so that I can show you how to set things up, but let me show you what it looks like in my actual main vault. This is my Games Index page, and these are the campaigns that I've played in or run. I still have the same Add New World button here and each one of these follows the same format. So for example, in this game which I am running, I have the sessions here that I can add and they are automatically incremented in the way that I showed you. As you can see, I play a lot of RPGs, I think I'm up to five weekly ones right now, which is a little bit too much honestly. But that's why I needed something like this. I know that this can be very daunting, but the reason that I did it was because I really need something that I can just click on and everything is done for me. It did take an initial amount of time to set it up, but afterwards it's a lot easier from there. Is this approach for everybody? Definitely not. This is a niche use case and a niche way to use Obsidian but I just thought I'd show it off since I've already made it. I've been hesitant to share my templates because there's no one right way to do note taking and I feel like my templates are so specific for my use cases. However, I get enough comments asking about the code that I use and the templates that I use that maybe there are more of you out there with similar use cases. So if you do just want to download everything that I've shown you here, then consider joining my Patreon and you'll get a copy of the vault that I showed with all the plugins and templates and settings and even shortcuts that I've shown for the goals and reviews, for meetings and people and also for the TTRPG workflows that I've demonstrated in this video. Automating my notes with Templater helps me do two things. One, it saves me time by allowing me to populate my notes with predefined fields. And two, it helps me keep my notes more consistent with each other by providing me a repeatable structure that I can work from. I said earlier that Templater won second place. Any guesses as to which plugin won the Obsidian Gems of the Year in 2021? That would be Dataview. It is also a very powerful plugin, but also a little daunting and overwhelming. So check that video out if you wanna know more about it. Thank you for watching. (speaking in foreign language)
Info
Channel: Nicole van der Hoeven
Views: 103,279
Rating: undefined out of 5
Keywords: note taking, obsidian md, obsidian tutorial, obsidian templates, obsidian app, obsidian notes, obsidian plugins, obsidian for beginners, note taking app, obsidian workflow, how to use templates in obsidian, templates in obsidian, obsidian app tutorial, obsidian app overview, obsidian templates tutorial, obsidian templates examples, obsidian templates script, obsidian templates vs templates, how to create templates in obsidian, obsidian tutorial dnd, obsidianmd dnd
Id: 5j9fAvJCaig
Channel Id: undefined
Length: 18min 3sec (1083 seconds)
Published: Fri May 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.