Folder properties / Add tag on note creation based on the note's folder

What I’m trying to do

My specific use case is that in the process of note creation, I’d like to have a tag automatically added to a note, based on the folder it’s created in.

The folder would have 1 tag defined on (/ assigned to) it, that may or may not match the folder name. All notes created in that folder would fetch/inherit that tag on note creation, in addition to whatever else is added to the YAML via other means (e.g. Templater).

In my desktop workflow, I most often create notes via right clicking on a folder and using the new note menu item.

Things I have tried

I have a few Folder Templates setup in Templater for more specific note types. But most notes use a single basic note template. I could assign a unique template to every folder via templater but that’d be cumbersome to setup and maintain (too many folders, among other problems).

I also noticed that the Tag Folders plugin allows for right-click new note to be created, which is great, but you can’t control the folder location the note is created in (I think it uses the current folder tree selection). I prefer to use real folders, rather than tag folders and want to avoid having to go back and sort notes after creation. Plus I have a lot of tags that don’t need to be real folders, so my tag folder tree is harder to navigate.

Ideally, I’d like to keep using the right click creation workflow. But mostly, I’m looking for more efficient way to assign a tag to a folder and then fetch that on note creation (e.g. via my basic note template).

Couldn’t you do this by extending your basic note template to have a folder detection, and check whether this folder should have a designated tag or not?

Through either of the tp.file or tp.config parameters, you should be able to get the path of the file, and then you could use that as a lookup in a predefined list to get the tag.

That’s a pretty good idea. It might be the winner.

The main “downside” is that instances where the tag doesn’t match the folder name would have to be added to the lookup, situated in the template and be edited/extended there, when I add new folders.

Downside in quotes, because it’s probably a similar amount of editing to set the data… :thinking: I can’t quite put my finger on why at the moment but I prefer something about avoiding the lookup table in the template and setting the property on the folder as and where needed.

I guess setting data on a folder would either mean a small data/config file in each folder (not a fan of that) or a global data file where the reference is set (not unlike the lookup file in basic note template). Iconize ( / Folder Icons …did the name change recently?) does something similar when it assigns Icons. I wonder if there’s something to mimic there.

And exactly how would you connect a property to the folder? There isn’t any specific file associated with a folder per default.

I’m thinking the best and easiest place would be either directly in the basic note template, or if you want to extract the functionality from there in a Templater user functions. In either case, it would be one place to update as you add a line for each folder with the folder name and the tag.

Yeah, that’s basically what I was musing on in the 3rd and 4th paragraphs.

The Template solution will probably be the one that requires the least extra stuff. There might be some other plugin out there or some other solution that can do it, but I’m not really expecting it.