Can you hide the "Metadata" box when previewing a note with YAML metadata?

Hello, Obsidian folks,

Does anyone know how to hide the “Metadata” box at the top of a note with YAML metadata when in Preview mode?

I saw a video that showed the YAML metadata only in Edit mode, and it was completely hidden in Preview mode, which is exactly what I want – but in my vault any note with YAML metadata causes a big “Metadata” box to be shown at the top of the note. I suspect the video I saw may be using an older version of Obsidian, as there seems to be no way to hide the “Metadata” box in Preview mode.

I would have thought that the “Show Frontmatter” option in Settings would let you turn this off, but no – with this option turned on, you see both the “metadata” box and the unformatted metadata as a code block, and with it turned off you still see the frontmatter displayed in the metadata box. So despite the name it unfortunately doesn’t seem to let you hide the frontmatter at all.

I’d like to use YAML metadata, but having it show up as a box at the top of every note just clutters the way notes are displayed – I find this so distracting that I’ll avoid using metadata entirely if I can’t somehow hide that box. Is there some way of turning off the “Metadata” box in Preview mode that I don’t know about?

Thanks!

3 Likes

I use the Hider plugin for this but I’m not sure if there’s another way of doing it.

3 Likes

Thanks, @jlc – I’ll check that out.

It does seem weird, though, that there’s no built-in way of hiding the frontmatter. It seems pretty seriously distracting the way it’s implemented now…

Is the YAML on the top line and bound by three dashes?

https://help.obsidian.md/Advanced+topics/YAML+front+matter

Angel

Hi Angel,

Is the YAML on the top line and bound by three dashes?

Yes – if I don’t have the YAML right at the top and surrounded by three dashes, it isn’t recognised as metadata at all. It’s easy to tell this because then the “METADATA” box doesn’t appear at the top in Preview mode, which is what I want, but then the metadata isn’t accessible either so there’s not much point in having it in the file at all.

Hi ewestra.

For me, the bound YAML hides in preview. Was checking whether inline YAML, with two colons, was being used. Are you using a theme? It you temporarily disable that, does it work with the default settings?

Have you got the version of Obsidian released yesterday?

Angel

test.md (364 Bytes)

1 Like

Hi Angel, I’ve dug a bit more and can see why you’re not seeing YAML metadata. It’s nothing to do with the version of Obsidian, or the theme being used – I’m running the latest version and tested both with my customised theme and with no theme at all.

The issue is the particular metadata you’re using. If you just list unknown metadata types (like your key, key2, etc) then the “METADATA” box doesn’t show up. But as soon as you use a supported metadata type (like aliases), the box shows up:

So it’s just the type of metadata you’re using – unfortunately the box shows up as soon as you have a supported metadata item, and there doesn’t seem to be any way of hiding it unless you use the “Hider” plugin.

2 Likes

Try this css snippet (I didn’t try it, not sure if works):

.frontmatter-container {
    display: none;
}
16 Likes

Standard YAML hides, but Obsidian aliases don’t.

Was not stated in the thread until now that you were dealing with aliases.

Thankfully, mnvwvnm’s snippet does hide aliases.

Angel

1 Like

This is what I use in my theme. Works perfectly.

Standard YAML hides, but Obsidian aliases don’t.

Was not stated in the thread until now that you were dealing with aliases.

Thankfully, mnvwvnm’s snippet does hide aliases.

Sorry, I wasn’t making a distinction between different specific keywords, just YAML in general. It’s strange that the behaviour is contingent on which particular YAML keywords you happen to use in your note – if you use a keyword recognised by Obsidian the box appears, but if you don’t then the box won’t appear. I looked at using aliases a while back but gave up when I saw what effect they had on the rendered note in Preview mode…but I’m also interested in YAML in general as a way of adding metadata to my notes, and with the current behaviour I’m very reluctant to do so.

Yes, using a snippet like @mnvwvnm’s seems to hide it, which is a good workaround. It just seems odd that the behaviour built into the app results in such a distracting view in Preview mode…do people really use notes with metadata and just live with having that big box at the top of every note?

4 Likes

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