What's better: Tags at the end of text or tags in front matter?

I am starting to use tags in my vault. by looking at forum and help I found out there are to places for tags:

  1. In the text (I put them at the end of text)
  2. In the front matter?

What are the advantages of both? What is more recommended?

Many thanks in advance for any pointers!

TL;DR:

Both.

Disclaimer

I use Obsidian as a note-taking enabled database app, rather than a zettelkasten app. This means that your mileage with my approach might vary, and that others in the forum may have strongly held views that disagree with mine :slight_smile:

YAML

I use YAML and templates to define a type of note. I then use dataview to bring various notes of different types into a coherent view. For example, I might have a people_template that collects some standard YAML around a person. This could be:

---
aliases: [nickname]
first_name:
last_name:
birthday: DD-MM-YYYY
where_we_met:
currently_lives_in: city
tags: person
---

I store this in YAML, because ideally I would want this information to be consistent for every person note. That then allows me to do some really simple things with dataview, like:

#### Near
```dataview
list 
from #person
where contains(currently_lives_in, "city") and file.name != "this person"
limit 3
```

That said, I also use tags within text. Specifically, there may be particular notes or bullets that I want to send forward in time.

For example, say I am having a business meeting with a new acquaintance and they mention off hand that they dabble in crypto. I could leave my meeting note and hop into that person’s person note (which would disrupt my focus) or I could use a tag to send this comment forward in time.

Specifically, what I do with my person notes is this:

---
aliases: [nickname]
first_name:
last_name:
birthday: DD-MM-YYYY
where_we_met:
currently_lives_in: city
tags: person
ref: person/firstname_lastname
---

and then:

#### Touchpoints
```dataviewjs 
const pagesWithQuotes = await Promise.all( 
	dv 
	.pages("#person/firstname_lastname") 
	.map(pageWithQuote => new Promise(async (resolve, reject) => {
		const content = await dv.io.load(pageWithQuote.file.path);
		resolve({ 
			link: pageWithQuote.file.link, 
			content 
		}); 
	})) 
); 

// Create an array of pages containing quotes, 
// where each page is: 
// { 
// quotes: [], // array of quotes 
// link: { path: '' } // Link 
// } 

const quotesByPage = pagesWithQuotes.map(({ 
	link, 
	content 
}) => ({ 
	link, 
	quotes: content 
		// Split into paragraphs 
		.split('- ') 
		
		// Get only paragraphs that have the #person/firstname_lastname tag
		.filter(content => content.includes('#person/firstname_lastname')) 
		
		// Remove the "#person/firstname_lastname" tag from each quote string 
		.map(content => content.replace('#person/firstname_lastname', '')) 
})); 
quotesByPage.forEach( 
	page => 
	page.quotes.forEach( 
		quote => dv.paragraph(`${quote} (${page.link})`) 
	) 
); 
```

Writing something like this in my meeting note:

- Likes crypto #person/firstname_lastname

Will dynamically return as:

### Touchpoints
- Likes crypto (@meeting with firstname 2023-02-28)

In the person note.

That means that I can stay completely focused on my meeting while using tags to capture interesting comments on the fly. The benefit of using this approach is that the person note doesn’t have to exist in the vault ahead of my call. I can create it later and use Templater to generate the touchpoints script above.

The second benefit of this approach is that it sorts the wheat from the chaff when capturing comments from people I see often. I might meet a co-worker twice a week for 3 years… that’s a lot of backlinks with a lot of noise.

I will add that I find the Tag Wrangler plugin absolutely indispensable for doing this. It lets me nest, rename, and organise tags on the fly, so that I don’t have to worry about loose ends in my vault.

7 Likes

Super detailed info! Thanks. I didn’t know that you can turn Obsidian into a database!

Not sure how applicable this is for plain notes use… I think having tags in only one area (YAML or end of note) makes things more consistent…

It all depends on what you want to use your tags for, and what’s the target of the tag, so to speak. There is also something to be said on the lifespan of a tag

Pure placement of tags

If you want to tag a note, it belongs in the frontmatter, if you want to tag a sentence or a section, it belongs in the text. So then question becomes why would you want to tag either of those.

I’m tagging sentences/blocks/sections mostly due to the need to action on that piece of text. Like if you want to tag a task as the #next task to do within a list of task, or if you want to #rewrite a part of some text, or #continue-from-here (not a good name but it kind of indicates that this were you left reading that article/note, and where you’d want to continue on a later stage). All of these belong in the text, and are ready for searching and locate the pinpoint of their importance.

On the other hand, a note can be tagged with some of the more actionable tags, like #rewrite or #split, but it can also be tagged for more organisational causes, like type of note, like #person or #reference, or which period it belongs in. E.g. I tag most of my daily notes with something like #year/2023/02.

And some belong in both categories, like I tag people in my vault with #P/NameOfPerson, and this is placed in the frontmatter at the main page of the person, and just in the text when I’m placing a weak reference to the person within a note. (For a stronger reference I used the link to the note)

Longevity of tags

Another point I would make whilst on this subject, is that for me there is also something related to the longevity of the tag, which needs to be addressed. I’m slowly moving to the stance that nothing should be tagged in the long run, and that tags are for shorter time spans (or more unorganised organisation purposes). (This is a work in progress, or something I’m contemplating myself, so it’s not written in stone)

I’m starting to lean towards that tags are mostly used for searches, and not established connections. This can clearly be seen when using tags like #nextAction or #waitingForSomeone, or other action-related tags. These will naturally shift as time goes by.

It’s not as clear but when you start to use them for pure organisation purposes like tagging a note with the type of note, I’m thinking that this usage should probably be turned into a field of its own, and not stay a tag. Due to this I recently moved all my tags of #journal, #reference, #travel into a type: field in the frontmatter. This’ll transform an unify some of the scripts/queries I’m using, and solidifies the meaning of this markup.

This is also the reasoning behind the “unorganised organisation purposes” statement above. I’m thinking tags are great to use when you’re not entirely sure how to organise it, and you’re still working out the details and how you’d like it to look. Then using tags is easy, and fast, and reworkable. The tag section is the right side pane is then a very useful tool, and you can easily see when some tags rise from being an occasional markup, into something more substantial.

These are the three top tag sections in my vault:
image

And from this I can see that I should consider switching the #År/... (aka #Year/... tag into something more permanent, to avoid cluttering up the tag list, and similar I could/should consider doing something similar for the #P/... (for people) and #SO/... for (Places and Organisations) structures. But the latter two I’m using also for weak referencing, so they will most likely stay as is.


In summary, I think tags belongs in both frontmatter and the text, due to the nature of tags being used in queries and searches, and then placed accordingly to whether they refer to the note or a smaller context. And that one should also consider for how long a tag should remain a tag, before being moved into another markup like a field in the frontmatter (or text), as I’m kind of thinking that tags should be short-termed, and move around a little.

5 Likes

Wow, thta’s a totally new perspective to me!

I use tags normally to describe the content of a note or to group notes by attribute for which the note should show up when I search for the attribute.

This means I have tags like math, python, sysop, internals, long-read or have-read.

Looks to me very different to your use of tags… What Obsidian feature do you use to describe the content of a note?

That’s an awesome method to blend together contextual notes (like a meeting note or a daily note) and the subject matter note. I’m going to give that a try. Looks like to implement you need dataview with javascript turned on. Do you need anything else done? Maybe create the referenced pages in the query?
Thanks for sharing.

Glad to hear it :smiley:

I’m only using dataview with JS enabled. You can add the tags before the subject matter note (i.e. person note) exists, as long as you’re using a predefined tag structure.

So for example, if I need to make a comment about #person/john_doe, I can do so before there is a note in my vault called “John Doe”.

Once I create such a note, I can then put ref: #person_john_doe in the YAML, update the dataviewJS touchpoints code, and see all the collected comments.

Sorry for a little sidetrack, but I kind of like the usage of ref: to indicate the “main” note for this tag, which leads to the question: Do you have a script collating which of these tags do or don’t have a main note? (aka tags using #person_.... not being present in a ref: field?)

@Edmund has a sample vault available on GitHub that includes the following thoughts about tags:

Why using Tags for Zettelkasten

I’ve learned that tags are best thought of as specially designated search terms.

I choose using tags for Zettelkasten with two different goals in mind:

  • to build up an index
  • to define clusters

Both methods of tagging support further searching:

  • The terms in my index are leading me to important entry points in the slip-box.
  • The terms which define clusters are leading me to a number of similar notes that belong together.

While tags for indexing should link only a few important notes, the entry points for further investigation, the tags for clustering connect larger groups of notes with similar focus.

Coming from Bear, which uses tags to define structure, I lurched to using Wikilinks when I started using Obsidian and now only have a few non-critical tags left in my vault (usually only used to test queries). Having read Edmund’s thoughts and ones shared here, I am rethinking my entire use of tags. That said, with changes coming to Obsidian’s approach to metadata, I will wait before making any wholesale revisions to the structure of my Obsidian brain.

Really interesting thread. Appreciated. :thinking:

3 Likes

Not at the moment - but that’s primarily because I operate on the philosophy of “don’t create a note until you absolutely need it”.

You could probably do a few things:

  1. Refactor the script to use the file name instead of a tag (and add the /people prefix dynamically within the script) - this would obviate the need for a YAML element completely
  2. Write a script that collects and returns a list of all the tags in the vault, then runs a for each loop on each of those tags to see if a file named x person exists.

@anon63144152 I am really excited about the upcoming release too. The new release + datacore could see me totally refactoring my approach.

2 Likes

Please write about it if you do. :thinking:

2 Likes

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