obsidian-linter icon indicating copy to clipboard operation
obsidian-linter copied to clipboard

FR: Copy title to aliases

Open chmac opened this issue 1 year ago • 3 comments

Is Your Feature Request Related to a Problem? Please Describe.

I use the title YAML field to publish notes. But in Obsidian, only aliases are searchable. So I need to manually copy title into aliases (as I don't have a leading h1 which has my title).

Describe the Solution You'd Like

It would be great to have an option for the "YAML Title Alias" section which sources the title from the title frontmatter key.

Please include an example where applicable:

Example filename: foo.md

---
title: Bar
---
---
title: Bar
aliases:
  - Bar
---

Describe Alternatives You've Considered

I'm not aware of any alternative strategy to achieve this, but I'd be happy to hear suggestions if there is a viable workaround. :-)

Additional Context

Thanks for Linter. Took me a while to figure out what this plugin could do as I assumed it was mostly linting, but it's incredibly powerful, and super useful coming from dendron into obsidian. 🧡

chmac avatar Feb 01 '24 11:02 chmac

I want this feature very much too.

If we only write H1, it will work fine. Then, "YAML Title" creates title frontmatter key and "YAML Title Alias" adds same value to aliases frontmatter key.

But this alternative cannot be used if H1 gets in the way in the post-process.

hkcomori avatar Jun 05 '24 09:06 hkcomori

Hey @chmac , @hkcomori , YAML Title currently has a mode that determines how it functions (see https://platers.github.io/obsidian-linter/settings/yaml-rules/#yaml-title). Would it make sense to just add a mode to YAML Title Alias to allow for this functionality where you can specify that you want the title alias to come from either the H1, the filename, or how it currently works? That seems the simplest change to me which would make it easier to maintain (hopefully) and get this added faster.

What do y'all think?

pjkaufman avatar Jun 05 '24 12:06 pjkaufman

@pjkaufman Yes, it would be great if the option could be one of Title key, First H1, Filename, Title key or First H1 if Title key is missing or Filename if H1 is missing for YAML Title Alias. The Title Key means the value specified in YAML Title. I think variable would match more use cases than the fixed key name title.

hkcomori avatar Jun 05 '24 15:06 hkcomori