Convert YAML Front Matter tags into DT tags

This could work like Tags > Convert Hashtags to Tags does now, except it would parse the front matter syntax which is

tag: ["tagname"] or tag: [tagname]

either seem to work in Obsidian

Use case: I use Obsidian alongside DEVONthink and this would allow me to tag using YAML Front Matter in Obsidian and easily turn them into usable tags in DEVONthink which is where I do my processing and searching for obvious reasons :wink:

I’m working around this by tagging outside of the front matter section, but I’d prefer to keep the tags hidden with the rest of the document meta inside the front matter.

PS: Obsidian is doing their own thing with Markdown. We try to follow standards and conventions when possible, even if the standard isn’t defined by anything more than the understanding and use of the majority.

I’m with you on standards. I totally agree. I believe I used that format based on this article and some template recommendations, but honestly I would use whatever is the more common approach.

Using tags in front matter in Obsidian and being able to easily capture them, preferably by a smart rule, as real tags in DEVONthink is my dream situation.

I don’t know if that’s possible directly with a rule.

It certainly is with a script which could be run from a smart rule: grab the love (edit: read “line”) beginning with "tags: ", isolate the tags themselves and add them to the tags property of the record.

This is so romantic! :wink: “Line” is just plain boring! (Sorry!)

Stephen

2 Likes

HAhahaha! :heart:

I’ve slightly amended the post to make it clearer. Swipe to type is full of surprises…

2 Likes

So, to answer @Andrew_Glaser’s question: yes, it is possible, but not without some work involved.

Just revisiting this topic. I’m new to Devonthink. Installed it two days ago, and indexed my Obsidian vault today. And realized that DT picks up #tags in text but doesn’t pick up tags in YAML frontmatter. I think that that would be a very good thing to have. But I don’t know how to script it. All and any help would be greatly and deeply appreciated.

Aren’t there multiple ways to format tags in YAML frontmatter? If all 3 formats below work:
tags: hello greeting
tags: [hello] [greeting]
tags: hello, greeting
how is Obsidian doing their own thing with respect to YAML frontmatter tags?

Which version of DEVONthink do you use, is the preference to convert hashtags to tags enabled? Finally, an example document would be useful as this seems to work as expected over here. Thanks!

Christian,

#Tags work for me in YAML headers, but the standard YAML headers aren’t converted to Properties in the same way that they are in non-YAML headers. IndexRawMarkdownSource is enabled.

Is this expected behaviour?

Thanks…

No. That’s why an example would be useful.

Create two brand new markdown files with exactly the same standard headers, Title, Authors and Keywords, the only difference being that one file has Yaml block separators (---) and the other doesn’t.

As you can see, the properties are automatically populated for standard multimarkdown headers, but not for YAML headers.

#hashtags work for both.

Secondly, as you can see from the second screenshot, YAML headers are not hidden in the Preview rendering. This doesn’t bother me particularly as I like seeing the headers, but it is a difference in treatment. It’s why I asked whether the behaviour is expected or not.

Am I doing something wrong?

Thanks!

Try only one separator after the properties, does this work?

It’s not the format expected by MultiMarkdown.

Yes, it works, but isn’t that because the only --- is treated as a simple divider? I.e. It’s not seen as a YAML block because of the absence of the first separator. (I could be wrong on this, I’m an expert in neither markdown nor yaml!)

I know multimarkdown accepts a subset of YAML metadata, but I don’t know how that translates to previews (and as I said, I actually don’t mind them being displayed).

My question was really why the properties are being ignored with the YAML headers and whether this is expected – it’s not referenced in the help as far as I can tell.

Thanks

DEVONthink’s parsing is consistent to MultiMarkdown’s rendering. If it’s visible in the preview, then it’s not metadata. But actually this works as expected over here:

That’s why the raw source of a document would be still useful.

No problem:

---  
Title: YAML Headers  
Author: Testy McTestface  
Subject: Testing  
Keywords: Test #test  
--- 

# YAML Headers

This raw text produces this result:

Works fine after removing the spaces after the separators.

2 Likes

For what it’s worth, if I use the following YAML at the start of a markdown file DEVONthink does tag the record appropriately:

---
tags: Humour
---

If I copy the header from your post and add that at the top of a markdown file it is not picked up by DEVONthink as YAML and, as you say, appears in the preview.

However, this does work:

---
title: YAML headers
author: Testy McTestface  
subject: Testing
keywords: test
---

I’m not quite sure why but I had to meddle quite a lot with your text to get rid of some strange emboldening (rogue code?). I’m unsure whether the initial lower case words make a material difference,

Edit: corrected typo.

Stephen

1 Like