Clickable tags property values in Dataview table fields

I have gone back and forth on this many times, so I thought I’d post here for community feedback…

(Also, found this discussion useful)

What I’m trying to do

I am trying to standardize my note templates and find a home for 2 main properties that are universal to all my notes: topics and tags. Tags is obviously both a built in Obsidian property as well as a feature. Topics is essentially a personal knowledge management strategy I am trying to implement to anchor my notes to evergreen parent notes that also serve as maps of content.

In order to accomplish the latter, I’m relying heavily on the Dataview plugin, such that a Topic note lists the other types of notes that are connected to it via the topics property. In these lists, I am also intending to show the value of the tags property for each note in the Dataview table. For example, here is a Dataview query on a Topic note that lists all non-topic notes point to it via their topics property:

TABLE tags AS "Tags"
FROM [[]] AND !#topic

My main issue is where (and how) do I put the topics and tags properties in my notes, such that I can use them consistently both in Obsidian and with Dataview? See below for more details on what I mean.

Things I have tried

I originally created properties inline at the top of the note (i.e., topics:: and tags::). To better visually organize these inline properties, I was placing them under a foldable callout with the title “Metadata”. This worked well (I could use them with Dataview and the tags, with a hashtag in front, were clickable in the table), however it was clunky to edit. Here is an example:

> [!info]- Metadata
> topics:: [[Productivity]]
> tags:: #software

When Obsidian introduced native support for properties, I started converting the inline properties to YAML front matter. Here is an example based on the above:

---
topics:
  - "[[Productivity]]"
tags:
  - software
---

This still works with Dataview, but there are 2 main issues:

  1. The tags in a Dataview table field are not clickable, and just display as plain text
  2. I don’t believe that the links to Topics will now show up in graph view because they are part of YAML and no inline

I can live with the second issue because I’m creating maps of content anyway. However, for the first one, I find that I have to remember to add a hashtag (#) in front of any tags I add as properties for it to still work. This results in the following, based on the example above:

---
topics:
  - "[[Productivity]]"
tags:
  - "#software"
---

I still get an autocomplete list when adding tags in the properties editor, but if I don’t remember to add the hashtag in front, they don’t display as links in Dataview. In addition, and this is a bit picky, but I now also have the extra characters in the source of the file that feel unnecessary.

So, with all that said, should I keep my properties in YAML and use the default tags format without quotes and hashtags in the hopes that the Dataview plugin may make special consideration for them in a future update (that is to make them clickable so one can jump straight into a search query based on that tag), or should I try to always remember to add a hashtag in front of all tags in YAML properties (at the risk of forgetting and having inconsistency in my notes)? Alternatively, should I go back to having properties inline and just deal with the clunky editing and display?

Maybe I’m overthinking this and being too particular, but I would love to hear what the community things. Perhaps there is even some Dataview query magic I can leverage to get what I’m after. Thoughts?

Let’s say we have a note like:

---
topics:
  - "[[Productivity]]"
tags:
  - software
  - dev
---

And a query like:

```dataview
TABLE "#" + T AS "Tags"
FROM [[Productivity]]
FLATTEN tags as T

We will get a table like this, where #software will trigger a tag search tag:#software

| File (2) | Tags      |
|----------|-----------|
| My note  | #software |
| My note  | #dev      |
1 Like

Thank you for this response! It seems to work for notes with a single tag, but when there are multiple tags, it is showing the note twice (now that I’m looking at your examples, I see the same). Is there any way to avoid this but still get the linking that this solution affords?

Try this:

```dataview
TABLE file.tags AS "Tags"
FROM [[Productivity]]

Output:

| File (1) | Tags        |
|----------|-------------|
| My note  | - #software |
|          | - #dev      |

And for the record, the example I wrote in the past post was hacky and foolish. You can achieve the same just using: file.tags


```dataview
TABLE T AS "Tags"
FROM [[Productivity]]
FlATTEN file.tags as T
1 Like

Awesome! It was as simple as that. Now when there are no tags, the column is just blank. Much cleaner. Thank you so much!

Based on the above solution, I’m going to stick with the YAML properties and keep the tags without the hashtag in front. The source text is cleaner and I still get clickable tags in Dataview tables :raised_hands:

1 Like

You should indeed keep the tags property free of hash signs, as that actually breaks the tags functionality of I’m not mistaken. They are supposed to be defined without it.

But I do secind the option of using tags and topics like you suggest, and the topics should in the more recent version of Obsidian be a true link and be found in backlinks and so on.

Lastly, look into the difference between using file.tags and file.etags, where the first will split all nested tags into their various sublevels, but the latter will keep them as they’re defined.

2 Likes

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