Insert precise heading links when there are duplicate headings in a note

Steps to reproduce

note.md
# headerA
content 1

## headerB
content 2

# headerB
content 3

Expected result

Expect use [[note#headerB]] to refer 1st-level headerB with content3,

Actual result

Link to 2nd-level headerB above content 2.

Environment

  • Operating system: Win 10
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v1.1.9
    Installer version: v1.1.9
    Operating system: Windows 10 Pro 10.0.19045
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: dark
    Community theme: none
    Snippets enabled: 0
    Restricted mode: on

    RECOMMENDATIONS:
    none


Additional information

I think should use Level-Header Path to refer 2nd-level “headerB” like [note#headerA#headerB].
In OS file system, same file/folder name on different path won’t be treated as duplicate.

This is not a bug — you should use [[#header A#header B]] to specifically target redundant subheadings (or strive not to use redundant headings if you’re creating links to them).

1 Like

Yes, I want to create links to both headings and subheadings, but when which name is duplicated in other heading path, will get the wrong target.

# a
1
## b
2
# b
3

![[#b]]
![[#a#b]]

will get two #b 2, not #b 3 and #b 2.

I’m seeing what you mean now, and can reproduce. [[#b]] gives a dropdown to let me choose either the H1 or the H2, but no matter which I select, I get the H2.

2 Likes

Okay, so in other words, selecting a nested heading when there are duplicate headings should insert a precise “pathed” link to the heading, rather than a single #heading link.

This is akin to how “shortest path to note” currently works when there are multiple notes with the same name.

I’ll rename the thread to be more specific and move it to feature requests.

2 Likes