Things I have tried
Searching docs and forums to see if this is possible. Can’t see anybody trying to do it other than me though (which surprises me …)
What I’m trying to do
I want to create a new note by selecting a template. By default this is created in the root folder of the vault.
What I want to do is specify in which folder a new note from a specific template should be created. There could eg. be multiple templates that create notes in my “Personal” folder. As it stands I can link a single template to a folder, and then all notes created there will use that template - this is great for daily/weekly etc. but not so great when I want multiple different types of notes in the same folder (to try and keep a relatively flat structure…)
- Book notes
- Project idea
- Story idea
Book notes, Quote and Person might all create notes under “Personal”, Project Idea might create a note under “Dev”, and Story idea might create a note under “Writing”.
Is this possible currently?
Templates are notes like any other. The reason why the templates/templater plugin finds them is because they are all in one specific folder. So “linking a single template to a folder, [such that] files created there will use that template” is not feasible (at least if this means that your templates are a little bit everywhere in the document tree).
However, “linking a single template to a folder” is still easily possible with templater plugin and a moving-promt. Just add e.g.
<% tp.file.move("/your-path/Quote/" + tp.file.title) %> to the Quote-Template and any file this template will be inserted to, will automatically moved to the respective folder.
If you have many similar (or even identical) templates for multiple folders and you want to avoid duplicating the templates, you may consider setting a hotkey for the
File explorer: Move file to another folder command (I use Ctr/Cmd+M).
Also for consistency between similar templates if found it is good advice to make a change-log note for your templates.
Hope this helps and my suggestion is not too much “the other way around”
Brilliant, thanks. I think Solution 1 is what I am looking for here - I can just put that
move in the header!
move file to other folder is also a useful shortcut to have though - going to add that anyway , thanks for the tip!!
Nice, happy to hear.
A short addendum to solution 1: If you put the command on a separate line you will end up with an empty line after inserting the template to the note. So just append it to any existing line and you will be fine
I noticed that. I put it in the YAML header and
<% tp.file.move("/your-path/Quote/" + tp.file.title) %>
gives an extra line. Interestingly
tp.file.move("/your-path/Quote/" + tp.file.title)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.