Custom handling of specific YAML keys

Hello there,

I have customised the way my YAML metadata is presented in different views and know, that you can specifically target the tags and aliases keys with different visuals using their custom CSS classes “.mod-tags” and “.mod-aliases”.

So, I have some YAML keys I’d like to specifically target just like it is possible for Aliases and Tags. I only have basic knowledge about CSS and HTML, and none as to how Obsidian sets these CSS classes.

Is there any way to custom specify .frontmatter-section child classes just like “.mod-aliases”, e.g. “.mod-abstract”?

I have tried to specify it as HTML code by wrapping the key+string in

and <\div>, though this did not work and only lead to the YAML being invalid.

Sorry, forgot to set it as code. I tried to wrap the key+string in <div class="frontmatter-section mod-abstract">abstract: "some abstract"</div>

See my reply here for a little more details on why this is hard:

To summarise, the tags and aliases have dedicated classes which make them targetable by CSS. The other don’t, and could to some extent be targetted by applying stuff like nth-child(). This however requires a very strict usage of order in the frontmatter, which is hard to do consistently.

I’ve seen some custom classes plugins, but I don’t think they’re applicable to the frontmatter. So I reckon you’d have to turn to some plugin, which could parse the frontmatter, and then add classes similar to the tags and aliases classes. I’ve not seen this plugin so far.

Another option could be to move stuff out of your frontmatter into inline fields, which has is pros and cons. One of the pros is that the fields themselves are then tagged with more classes than they’re in the frontmatter. But I’m not sure if that is a viable/wanted solution for you.

1 Like

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