Alias should be able to link directly to a heading

Use case or problem

Currently an alias sends you to the top of the note. It would be ideal if an alias could be configured to link directly to a heading.

For the note:

evapotranspiration.md
---
aliases: [evaporation, transpiration]
---

## Evaporation 

## Transpiration

The aliases currently link to the top of the page. My desired behaviour would be to configure the aliases in the yaml to link to the headings. The alias autofill would then give [[evapotranspiration#Transpiration|transpiration]] rather than [[evapotranspiration|transpiration]].

Proposed solution

Adjust the aliases frontmatter to accept a nested dict with {alias:heading} pairs.

evapotranspiration.md
---
aliases: [{evaporation:Evaporation}, {transpiration:Transpiration}]
---

## Evaporation 

## Transpiration

The alias would then autofill the appropriate heading link

Current workaround (optional)

Manually adjusting the obsidian link to include the desired heading i.e [[note|alias]] to [[note#desired_heading|alias]]

Related feature requests (optional)

2 Likes

This would make the more basic usage of aliases annoying.

I think a better solution would be a setting, plugin, or command to automatically change [[note#heading]] to [[note#heading|heading]].

To be clear I am not suggesting that aliases have to be given in the yaml as a {heading:alias} pair, something like

 ---
 aliases: [alias1,{heading2:alias2}]
 ---

 # heading1

 # heading2

would be valid and alias1 would become [[note|alias1]] while alias2 would become [[note#heading2|alias2]]. The basic usage would be unaffected.

I see, that is better.

I still think my suggestion makes more sense, tho. This seems like something a person would want to use every time they linked to a heading. A simple setting would save a lot of hassle over having to set a bunch of aliases.

I was actually in the process of creating a feature request about this, though with a slightly different use of front matter. I’m going to copy the proposed solution from

Proposed solution

I was going to suggest using a special character to act as a delimiter in a given alias. a # wouldn’t work as that is the start of the comment. @,+,=,~ all seem to work (in that they don’t seem to break frontmatter or change how the text following them is interpreted).

I’m guessing the note titles and aliases in a trie or some similar data structure, this would add a single character check that acts as a delimiter.

to demonstrate:

---
aliases: [foo@bar]
---
## bar

however a dictionary for aliasing to headings would work to, and I think that could also be more flexible (to alias to paragraphs)

1 Like