Links to header in the same file not working properly especially those that are Heading 2

What I’m trying to do

I have links in files that point to headers within the same file (i.e. table of contents). I am creating a table of content having a link to each section using back to top. But it is not working properly. this issue mainly affects Heading to as Everything Heading 2 link is not working. though there is somewhat issue with heading 3

Here is the the https://github.com/M-Talha4/Sample/blob/main/README.md as you can see the using[[]] are not the best solution as they are not portable.

Things I have tried

Using [[#name]] works but that is only for obsidian and won’t work outside.

When i share file this link becomes [[#Name]] as a simple text.

So you have this:

2. [[#Basic Content]]
	- [Headings](#headings)

One is a Wikilink and the other is an MD link: Internal links - Obsidian Help

I’m not sure if it’s best practice to use both of them, but I would suggest using one or another. In the options, you can toggle Wikilinks on/off.

image

Hope this helps you somehow.

Cheers, Marko :nerd_face:

Thank you for your response. I am sorry for confusion. That file on git is just my md file while trying solutions so it a bit messy.

What i want to implement

	- [Headings](#headings)

what is actually working
[[#Heading]]

This issue is mainly occurring in heading 2 (##).

You can see back to top option in the there it is not working.

Hello.

In a local test, both versions below work. Do they work for you? :crossed_fingers:

[Table of Contents](<#Table of Content>)

[Table of Contents](#Table%20of%20Content)

they Both are working. The issue is that it only works in obsidian. i want to make it portable md. like if i open a random md editor these links should work on them too.

Think per cent encoding of spaces is fairly standard but perhaps not universal:

[Table of Contents](#Table%20of%20Content)

If other editors use a different syntax, I presume that’s an insurmountable conflict for Markdown alone. Perhaps possible with pure HTML?

Hope someone has a better idea.

So, this one …

<a name="top"></a>
.
.
.
<a href="#top">Back to top</a>

… works in VS Code and some OnlineMD editor. But not in Obsidian. And whatever works in Obsidian doesn’t work in VS Code or Online MD Editor.

OK, this one …

## Table-of-content
.
.
.
[Back to Top](#table-of-content)

… works in Obsidian and VS Code, but not on the Online MD Editor.

I agree with @Guapa and hope someone has a better idea, as I don’t have any.

Cheers, Marko :nerd_face:

1 Like

What is the problem you’re seeing? All of the Markdown links in your GitHub example work for me.

Fragment links to headings probably won’t work in all Markdown editors. Some probably don’t support them. The ones that do, convert headings to URLs in different ways. You could use HTML to manually add IDs to link to, but probably not all editors will support them (if I remember right, Obsidian doesn’t).

But some editors provide a heading navigation feature like Obsidian’s Outline.

1 Like