YAML hashtag implementation

Testing version: iOS 2.0 (10670)

What were you doing: Playing around with Bear’s implementation of YAML

What feature did you use: Hashtags inside a YAML header

What happened:

The note was removed from the tag sidebar.

What did you expect to happen:

I expected a tag in the YAML to still be seen in the sidebar. I remember reading something about this in the forum awhile back and the dev response was “we don’t want to manage two types of tags” or something along those lines.

I don’t understand this. Every other app I’ve used that also understands YAML, treats a hashtag as a hashtag no matter where it is in the note. So there’s only one type of tag: hashtags.

It seems to me that the current YAML implementation in Bear is only partially complete since the main point of YAML is to have a dedicated & structured area for all metadata… hashtags are metadata but lose their main use in Bear since a note using YAML properly (with hashtags inside the YAML header) will no longer show up in the sidebar.

I really hope the devs rethink the current YAML implementation and make it so notes with hashtags in the YAML header show up in the tag sidebar :pray:

For what it’s worth, I can’t reproduce this. I’ve created a note with a Yaml header and put a hashtag in it, and that tag appears in the tags list and the test note is listed there as expected. I was wrong, see below.

Hello there,

YAML has no practical use in Bear 2.0 and there are no plans to change that for now.
Why it’s in Bear at all then? For a couple of reasons:

  1. part of the CommonMark standard
  2. it’s useful when exporting a Bear note to 3rd party tools

The YAML frontmatter is a very niche feature and has no benefits for 99% of the Bear users, so we prefer putting more developer time into the features that have an impact on everyone.

I know that this is not what you wanted to hear, but we prefer to be clear on what’s the road ahead :slight_smile:


1 Like

Really? I was converting my custom metadata solution to yaml so it was a copy/paste. Wonder if that’s the issue? I’ma double check on my end. Thanks for the head’s up.

EDIT: nope not working on my end on iOS or macOS. Autocomplete works fine, but these notes do not show up in the sidebar for me under any hashtag added to the YAML header area.

Are you sure your note doesn’t have the tag somewhere outside the YAML header?

Based on what @Matteo wrote above, I think what I’m seeing is the expected behavior, but I would absolutely love to be proven wrong here!

Not really. Not in Obsidian.

My note consisted of the following:

tags: #thisisatest

# Test

It also worked with quotes around the tag, i.e., tags: "#thisisatest", which might be necessary for it to be valid yaml.

Not sure what you’re showing me here. When I was using Obsidian (granted this was over a year ago so memory fallibility applies), I could add a hashtag in the YAML and it would show up in Obsidian’s tag area just fine.

The image you’re showing me is a YAML tag yaml/tag in the header and then a hashtag in the body, #body/tag. I’m not sure what this is demonstrating :man_shrugging:

Adding the quotes shouldn’t be necessary for valid YAML (although it’s a multiword hashtag with spaces maybe it’s necessary, but I never use spaces in hashtags so I dunno). Also when you add quotes around it Bear formats it in RED for some reason so I dunno what that’s about.

Still though, I’m not seeing notes show up in the sidebar, with or without other hashtags in the body. So the note I’m messing with right now has this header:

And with no other hashtags in the body and it ONLY shows up in the main Notes area, not under the #.active tag in the sidebar as I would expect.

Are you seeing your note show up in the sidebar under the #thisisatest tag?

Yes — I’ve also confirmed that it works for #.thisisatest.

(This is on iOS, by the way, since I don’t have access to a machine with the macOS beta on it right now. But I can double check later if that’s likely to make a difference.)

I don’t think so. Were you using a plug-in or something?

In the image, I’m showing tags written two different ways in order for them to show as tags in the tag list - with and without a hashtag. Tags in the YAML header will not show in the tag sidebar with a hashtag prefix. It’s been this way in native Obsidian for at least a few years.

Anyway, this is all moot. YAML is in Bear for publishing.

Oh, hang on, I’ve managed to reproduce it: the problem was that on iOS my note wasn’t being interpreted as having YAML in it, I had written it incorrectly. So yes, it seems like you’re absolutely right, sorry for the misunderstanding. The content of the yaml metadata block is treated as if it was just text, I think, a bit like a code block, with no special behaviour; a string starting with # inside yaml metadata is not a hashtag. Similarly, it seems like [[Blah blah]] isn’t treated as a wikilink inside Yaml. (Although weirdly it does autocomplete, it’s just not clickable — again, like code blocks.)

I can see why they’ve done it this way — if they don’t really want to support yaml metadata, treating it as just a code block is probably the simplest way. But it’s a little bit of a shame, since I had been considering adding metadata blocks myself, and if I can’t put tags in them it makes them less useful.

No I 1000000% appreciate the clarity. Over the years I’ve avoided using YAML even though in principle I love it, simply because it has super spotty support across apps.

But to clarify the confusion in this thread

Assuming I have the following note, and this is the only note with the hashtag #yamlTest. Is the expected behavior in Bear 2 to see this tag in the sidebar or not to see this tag?

Tags: #yamlTest

# This is a snazzy note

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tempus quam pellentesque nec nam aliquam sem et.

YAML is technically a code block, so nothing inside it is parsed as metadata, so no it shouldn’t show in the sidebar.

Oh gotcha that makes sense. Like I said, I haven’t used Obsidian in awhile and can’t remember anything specific. But now I understand what @Matteo was saying months ago about not wanting to manage two types of tags, which your example clearly shows. I’m not into that either, and wouldn’t use it in Obsidian either if it required keeping two sets of tags in parity (however, if it was just a formatting thing I probably wouldn’t care too much).

It’s funny because in the app I use for writing published material (iA writer) I add all normal publishing-related stuff in the YAML but don’t add hashtags, however, hashtags show up in the sidebar just fine when they’re in the YAML area.

It’s too bad it doesn’t work this way in Bear. Sadface.

1 Like

Okay thanks for the clarity! I will continue to happily not use YAML in Bear :laughing:

Cool. Yeah I thought I was going crazy for a minute there :laughing:

This YAML thing has been one of my annoyances in Bear 2 mainly because I didn’t fully understand what the devs were doing, but now with all the clarity from this thread and the understanding that YAML in Bear is basically a flavor of code block, I’m no longer annoyed by the lack of hashtag support and fully understand why the devs don’t want to spend the time building full-on YAML functionality.

But I think we’re in full agreement that having hashtag support in the YAML would be cool, but ultimately not super necessary.

I’m not in the beta programme and can’t try it out myself. But since I’m too impatient to wait another week … I would like to come back to the topic “tags and frontmatter”.

Yaml-frontmatter are with “- - -” and markdown metadata without. In the following, I am only interested in markdown metadata.

Please have a look at the following example:

title: a random title
tags: #example1
status: whatever

All four lines before the first blank line are usually considered metadata.

Is #example1 recognised as a tag because it is not a yaml frontmatter?
Is #example2 recognised because, maybe, only the first three lines are metadata from Bear 2’s point of view?
Does Bear know metadata at all or only yaml-frontmatter?

No, tags inside the yaml-frontmatter are not recognized and the metadata is not used by bear.
We treat YAML as a code block and we don’t want the metadata to be another layer on-top Bear’s internal metadata.

1 Like

that’s perfectly fine with me.
This means markdown metadata (without - - -) is treated the same way (= ignored) like yaml frontmatter (with - - - )?
For me this is important, so I know where to place the tags for export.
Thank you.

By the way. md-export with extension .md instead of .txt would be nice. Not a big hassle, but more convenient.