Backlinks don't appear for Linked Headings

They don’t show up in the Backlinks Sidebar for some reason.

Steps to reproduce

  1. Create a [[Templates]] page with a section called ## [[Cafe Reviews]].
  2. Create a [[Cafe Reviews]] page with a link to [[Templates#[[Cafe Reviews]]]].
  3. Open the Backlinks Sidebar on the [[Templates]] page

Actual result

Notice that there aren’t any Backlinks which just isn’t true and means we’ve lost the Obsidian magic here.

Expected result

I would hope that Obsidian accounts for all backlinks. Backlinks to specific sections is particulary useful when cataloging large collections of content.

Environment

Operating system: Windows 10
Obsidian version: v0.6.0
Using custom CSS: https://github.com/obsidian-ezs/obsidian-comfort-color-dark

3 Likes

Links cannot contain nested links for now. (Also headings having links in them don’t work). I’m not sure if that will be supported in the future but I would recommend moving the discussion about nested links to #feature-requests

In your case, if you remove the [[link]] from your heading it would work again. For now I would recommend moving the link down to the body-text after the heading.

@Licat I may be confused about something, but it certainly appears that Headers with links in them work really well. At least internal links do. They work as I would expect in both Edit and Preview modes.

Although I don’t seem to need that anymore for what I was doing. Your suggestion simplified my notes and they still work as I intended. Thanks for the suggestion!

I’m open to moving this to Feature-Requests. Or even just deleting it since your suggestion worked for me. But first I’m curious if you have anything more to say about Links in Headings seeming to work well. Theoretically, it could streamline some presentations. It has some utility.

2 Likes

I agree there are definitely valid use cases for having links in the heading - the biggest headache comes from parsing the nested links when another note link to this heading. Sure, it’s something we could throw some engineering power to fix, but that may not be the best solution, especially if we’re concerned with data portability (if you ever want to convert to plain standard markdown), or interoperability with other apps that also supports [[wikilinks]].

Not sure what you mean, They seem to work fine as far as being able to preview the link or header formatting. Embed wouldn’t make sense, of course.

An alternative might be to allow matching [[foo#bar]] to a header containing [[bar]] and not just bar.

I like your alternative idea. Partial match could make it easier to use, but I’m worried for a few things:

  • If you have an exact match after a partial match, which one would it go to?
  • If you’re linking to a heading by only putting the important part of the heading, then the non-important part could probably be moved to the body-text of the section instead.

I wasn’t clear - I meant [[links]] in heading wouldn’t work if you try to link to the heading.

That makes sense. Also embed won’t work.

I used a file link in header mainly to get the back links, to see all the files where the same header is used. For example. [[Idea]]. But it is not as useful unless the text below the header is also shown in the backlinks pane. [hint!]

Partial vs exact match: I am fine with exact match but ignoring the [[]] – the idea is that the markdown special syntax gets out of the way when you preview the file and the match should be with the preview version. Perhaps this will be less confusing when you have WYSIWYG editing.

Also need to deal with the [display](link) case. I’d match with the display portion.

1 Like

Rather than “partial” match (which could be useful in its own right), you could also just strip out the [[]] on querying. So it queries based on the text and not the formatting (or in this case, linking).

So ## [[Cafe Reviews]] would be treated the same as ## Cafe Reviews. And if you had both in the file, a link to [[Templates#Cafe Reviews]] would just match the first in the file, since to the code they look the same.

Edit: Ninja’d by @scmwiz

2 Likes

That I’m considering stripping all symbols and replacing all whitespace with a single space for comparison. I think that would be a good enough solution that’s loose enough to allow basically any kind of heading, but also not so loose to get false positive hits. Also the auto-suggest would make short work of having to remember what matches and what doesn’t.

3 Likes

Here’s a working prototype:

3 Likes

Per suggestions and clarifications from @Licat, I’ve moved this from Bugs to Feature-Reqeusts.

2 Likes

As of 0.6.0 you can link to headers in the form of [[document#header]] but this breaks if the header itself contains a link, such as # [[joe smith]]. It breaks in multiple ways: both in not linking to the correct place in the document, and not showing backlinks. I am adding this as a feature request, but maybe it is a bug? Unsure…

Someone made a thread about this in the bugs category: Backlinks don't appear for Linked Headings
Looks like @Licat is considering options here.

1 Like