yarle icon indicating copy to clipboard operation
yarle copied to clipboard

Tag handling in templates

Open seatrout opened this issue 3 years ago • 2 comments

This is, I think, more of an enhancement than an issue. But tag handling in templates needs to be improved for true compatibility with Obsidian.

The problem is that Obsidian accepts tags in two forms

  1. in the body of the note, when they are prefixed with "#" and there is no space immediately following. Yarle handles that case fine

  2. in the metadata block. That has to be right at the top of the note, and delimited with --- above and below. Inside that block you can have an entry for Tags: followed either by a comma-delimited list inside square brackets or a markdown-style list where each successive tag is on a new, indented line, starting with - see the reference here

The default template in v.4.0 ignores this convention and puts the title above a triple-dashed section, which Obsidian won't recognise as a proper metadata block. That should be fixed.

But it would also be helpful if multiple tags could be output separated either by commas or by indented dashes. That's easy enough to fix after the fact but it would be classy if Yarle could do it for me :-)

seatrout avatar Apr 06 '21 14:04 seatrout

Tag formatting would be a nice feature, but there is workaround for anyone running into a problem with tags in front-matter. Obsidian does recognize multi-line YAML syntax. You can output your tags like so in your template and still use hashtag syntax:

---
{tags-block}tags: >
  {tags}{end-tags-block}
---

Note that it is important to use the correct YAML format of 2 (and only 2) spaces before the {tags} on the second line, otherwise Obsidian won't recognize them.

montemartin avatar Mar 03 '22 03:03 montemartin

Hi all, @seatrout , @montemartin , Thanks for raising this up, I'll try to implement/fix it asap.

akosbalasko avatar Mar 03 '22 06:03 akosbalasko

Hello there. Thanks for all the hard work @akosbalasko. I'm wondering if there has been any progress on the tag handling in the front matter? According to the documents linked below, while obsidian will recognize tags in front matter that are listed as such:

tags: one, two, three

it is recommended to use the standard front matter syntax for maximum compatibility with other tools. Two forms are recommended:

tags: [one, two, three]

and

tags:
    - one
    - two
    - three

https://github.com/arnau/obsidian-metatable/blob/main/docs/sections/tags.md

TrustTepee avatar Oct 27 '22 21:10 TrustTepee

hi @TrustTepee , I'm sorry, but still had no time to implement it. But I'll do it around this weekend. Thank you, and sorry for the long delay.

akosbalasko avatar Oct 28 '22 07:10 akosbalasko

Fantastic. Thank you for making this tool. I spent a full day trying different options and yours is the only one that works properly!

TrustTepee avatar Oct 28 '22 15:10 TrustTepee

Hi @TrustTepee , I released the solution, you need to add tags-arrays block in your template, I detailed it here: https://github.com/akosbalasko/yarle/blob/master/Templates.md#example-tags-array-template And set useHashTags config parameter to 'false' in order to prevent adding hashmarks before the tags.

I close this ticket, but don't hesitate to create a new issue if something still doesn't work.

akosbalasko avatar Oct 30 '22 07:10 akosbalasko

Thank you!

TrustTepee avatar Oct 31 '22 00:10 TrustTepee