Refresh of tag property field

Hi everyone,

I’ve been using Obsidian for a while, but most recently have been trying to make proper use of some of my plugins.

Currently, I was messing with Templater, and trying to add a property field group at the start of each new note, where I would have the creation_date, lastmodified_date, along with a tag field.

The first two work fine, but my struggle with tags is two-fold:
(1) The command <%tp.file.tags%> does not seem to work, and I can only manually add them to this properties field;
(2) I’ve tested the tp.file.tags command on another note, outside the properties field, and indeed it does return existing tags on the note. However, if I add additional ones, it does not update.

Maybe this is not an intended feature - to have tp.file.tags on the properties field - thus why it does not work how I supposed it would, but if anyone knows a workaround to this, I would very much appreciate it.

Thanks,

AC

I might not understand your use case, but there are some concepts I would like to address in your original post.

First of all, when a template is inserted/executed it replaces the template stuff with the new text. This means that it’s a one time operation (in most cases), so it’ll not keep updating itself if you do other changes later on.

Secondly, if you create a new note using some template, and you add something to the frontmatter/properties, then tp.file.tags will be empty, as that get its values before the template is executed. tp.file.tags is meant to be used when you insert a template into an existing note, where it then could use information already present in the note.

So what do you mean with "to have tp.file.tags on the properties field` ? This doesn’t really make sense to me.

Thank you for your reply. I’ll try to clarify. Maybe i’m mixing terms that don’t make much sense, as I’m not very proficient in this subject.

This means that it’s a one time operation (in most cases), so it’ll not keep updating itself if you do other changes later on. […] tp.file.tags is meant to be used when you insert a template into an existing note , where it then could use information already present in the note.

Indeed, this is something I noticed and that got me looking if there was any option to “revert” back to the original “code”. This would mean that after executing the hotkey to activate the frontmatter, it would refresh itself, along with any tags that were added after along the note editing.

So what do you mean with "to have tp.file.tags on the properties field` ? This doesn’t really make sense to me.

My main idea was to have a frontmatter where all the note tags would be displayed. This obviously works when the note is no longer work-in-progress, and executing the command would fetch any existing tags on it. But, if its still being actively populated, I would have to wait until the very end to run the command - and even so, I could somewhere in the future return to it and face the same issue.

This being said, would there be any way to create a frontmatter field where tags would be automatically grouped as i actively edit my note and populate it with tags?

Using Templater you’re able to retrieve all of the frontmatter from a given field, and possibly restructure them to some extent using various API calls to change the frontmatter. However, if you’re using the ordinary user interface, and to some extent the API calls, Obsidian will occasionally rewrite the frontmatter. I don’t think it’ll change the order of the tags, but then again it also depends on what you mean with “automatically grouped”.

AFAIK, there’s no way to revert an template. You could do stuff like suggested in previous paragraph, and there is also an option to fully rewrite the file through scripting. I wouldn’t go down that path though, as you then could risk invalidating your files if your script misbehaves in some way.

So the question then becomes: How and why do you want this automatically grouping, and are you just talking about tags or also other fields in the properties/frontmatter. Could you show some examples of how it looks, and what you would like it to look like?

What kind of changes do you want to implement related to a “revertion” if that had been an option?

One example where this implementation fails is the following:

image

I have a property option which is tags, that only accepts #tag, thus the command does work and it doesn’t add the tags that are on the note.

Creating another property field of text type, doesn’t retrieve the existing tags either. When executing the hotkey, it remains empty

image
image

However, it does work outside of the property field:

image
image

But then, lets say that i edit the document and add an additional one (tag2) i can no longer display it on the tags “field”.

image

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