Search code examples
githubreadme

Github README file special character in table of content link


In README.md I have a 2 levels of section :

# Topic

Some text

## Foo & Bar

More text

I want to make a table of content which links to the Topic and Foo & Bar, I tried :

- [Topic](#Topic )
  * [Foo & Bar](#Foo-&-Bar)

The above "Topic" link works correctly, but the Foo & Bar doesn't link to the corresponding section. Where am I wrong?


Solution

  • You need to write the link #foo--bar like:

    - [Topic](#Topic )
      * [Foo & Bar](#foo--bar)
    

    Which you can find out when you inspect the readme with the developer tools in the browser, it looks something like:

    enter image description here