How would I get YAML variables to also be registered as tags in the front matter?

What I currently do

I use QuickAdd to give me the ability to add variables to notes when I refactor. i.e. I have a simple QuickAdd macro that calls the “refactor note” hotkey and then calls a QuickAdd “capture” that calls a front matter template, prompts me to enter the information, and adds the completed front matter to the top of the refactored note.

The front matter template is simply -

---

note_type: {{VALUE:note type}}
note_bucket: {{VALUE:note bucket}}
note_subject: {{VALUE:note subject}}
note_entity: {{VALUE:note entity}}

---

What I would like to add

I would also like to have note_type, note_bucket, and note_entity registered as tags in the front matter.

(Caveat -I am not a coder, but I’m slowly learning how to do things in Obsidian.) I can’t figure out the correct way to set this action up. I thought adding:

tags: {{note_type}}, {{note_bucket}}, {{note_entity}}

to the bottom of the front matter template above would work, but it just returns the variable names, written as:

note_type: meeting
note_bucket: Wiggins
note_subject: When I grow up
note_entity: BU

tags: note_type, note_bucket, note_entity

I’m sure this is a simple thing and I’m missing the obvious, but I can’t seem to connect my need to any of the YAML literature online

Cheers

Hope this Helps

I need to start out by saying I am not a coder either. Had a similar question and found a guy on you-tube that helped me make my system work. Here is an example from a template I set up for recipes files

---
tags: [" #Recipe #Main_Ingredient #Meal #Chef #Cuisine #Means"]
---

I take these as hints for what tags I want to use. The important thing for me is to have a dropdown - suggestion as you would if you used tags regularly. The format is the key, square bracket, quotes, space then tags with hash as usual. With my system these are jumping-off points, as I write the note I change the info to suit. Most of my tags are 2 levels, so I may have #Meal/Mains, that starts here as #Meal. Not certain that it helps you as much as you were hoping, but maybe a place to start?
This is the video that helped when I was setting this up, perhaps it gives you an aha! moment too!
How to use YAML in Obsidian correctly - YouTube starting at 7:00 for dealing with tags.
Good Luck

Finally had time to figure this out and it’s deceptively simple for us non-coders. The QuickAdd macro capture format is:

---
note_type: {{VALUE:note type}}
note_bucket: {{VALUE:note bucket}}
note_subject: {{VALUE:note subject}}
note_entity: {{VALUE:note entity}}

tags: 
    - {{VALUE:note type}} 
    - {{VALUE:note bucket}} 
    - {{VALUE:note entity}}
---
1 Like

Nice find!

In case it is useful, I thought I’d share my understanding of what is going on here. QuickAdd {{VALUE:my-answer}} saves the result of the prompt in my-answer, so you can then re-use that result with {{VALUE:my-answer}} elsewhere in your capture/template. You can do something similar if you ever need to do a prompt for a date with {{VDATE:my_date_value}}. (Your stored VALUE names are much better than my examples, since they actually describe what is saved in it!)

Random note: As someone with some coding knowledge but not very much QuickAdd knowledge, I am a little surprised that spaces in the names of saved VALUEs work correctly! But if it works, it works.

I’m glad this helps you. I understand what you’re saying about the spaces. I started teaching myself Python a few weeks back for something different to learn, so understand more about variables.

Apparently, in the case of QuickAdd format, the {{VALUE:note type}} actually corresponds to triggering an input box for a variable, where the input box has a title shown as “note type”. So “note type” is, I guess with my newborn knowledge, actually, a string assigned to the title of the input box, it just doesn’t have the quotation marks around it.

e.g.

1 Like

I think I misunderstood…so ignore what I’m telling you about understanding what you’re saying about spaces. It may just be that the variables are being listed in order. Let me try a couple of things real quick…Okay have a look at the screen shots below, the {{Value:note type}} appears to allow identification of, thus reading from, the variable note_spaces. I’m not sure of the synx to just display a variable in QuickAdd; I’ll look at that later today when I have a break.

Using

---
note_type: {{VALUE:note type}}
note_bucket: {{VALUE:note bucket}}
note_subject: {{VALUE:note subject}}
note_entity: {{VALUE:note entity}}

tags: 
    - {{VALUE:note type}} 
    - {{VALUE:note bucket}} 
    - {{VALUE:note entity}}
---

image

Using:

---
note_type: {{VALUE:note type}}
note_bucket: {{VALUE:note bucket}}
note_subject: {{VALUE:note subject}}
note_entity: {{VALUE:note entity}}

tags: 
    - {{VALUE:note entity}}
    - {{VALUE:note type}} 
    - {{VALUE:note bucket}} 
---

image

So not just in order of entry

Using:

---
note_type: {{VALUE:note type}}
note_bucket: {{VALUE:note bucket}}
note_subject: {{VALUE:note subject}}
note_entity: {{VALUE:note entity}}

tags: 
    - {{VALUE:note_type}} 
    - {{VALUE:note_bucket}} 
    - {{VALUE:note_entity}}
---

image

The tags are the text I entered in the second set of input boxes that popped up.

The bottom behavior: that if you give the variable names after VALUE new names then you get new input boxes, makes sense to me.
If you rename all variables inside {{VALUE: }} to use underscores, does the behavior make sense?

Thanks for sharing your experiments!

Yes, underscoring using this:

---
note_type: {{VALUE:note_type}}
note_bucket: {{VALUE:note_bucket}}
note_subject: {{VALUE:note_subject}}
note_entity: {{VALUE:note_entity}}

tags: 
    - {{VALUE:note_type}}
    - {{VALUE:note_bucket}}
    - {{VALUE:note_entity}}
---

Gives this:

image

The input boxes are titled with underscores, which offends my sensibilities, but is tolerable

and checking, using this:

---
{{VALUE:note_type}}
{{VALUE:note_bucket}}
{{VALUE:note_subject}}
{{VALUE:note_entity}}

tags: 
    - {{VALUE:note_type}}
    - {{VALUE:note_bucket}}
    - {{VALUE:note_entity}}
---

gives this:

image

But that doesn’t work with data view, I assume because QuidAdd just lays down the text and so now my taxonomy is not assigned to any data view accessible variables in the front matter. It also doesn’t tell someone looking at the note the string to which a particular variable is assigned.

It would, however, be fine for tags, but then you would just discard the top and use:

---
tags: 
    - {{VALUE:note_type}}
    - {{VALUE:note_bucket}}
    - {{VALUE:note_entity}}
---
1 Like

Thanks for sharing all of these! I am glad the results are more consistent now.

Exactly!

If you do not like underscores, maybe you could call your dataview fields “bucket” or “nType” or something? They do not have to match the names in the text that QuickAdd lays down. Still no spaces though.

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