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

3 Likes

HAhahaha! :heart:

Iā€™ve slightly amended the post to make it clearer. Swipe to type is full of surprisesā€¦

3 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!

1 Like

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

2 Likes