spicybbqfish
spicybbqfish

Reputation: 21

Gitbook header add id and internal links

I am new to the programming community and new to Gitbook. I have searched gitbook doc but still having some syntax problems.

I have been trying to add internal links so that, on a long web page, I can click links on the top of the page and it will directs me to content blocks contained in the bottom of the page. I also have a few long pages.

[Clickable Link1](redirects to headerId1 in the same page)
[Clickable Link2](redirects to headerId2 in the same page)
...

Real Content
Header 1 with id = headerId1
Content1

Header 2 with id = headerId2
Content2
...

The resources I had looked for involves: https://gitbookio.gitbooks.io/markdown/content/syntax/links.html

The problems I am having is:

  1. add id to headings.

    I tried to type ### Header1 {#id=myheader1} After typing ### and followed by a space, the Header1 {#id=myheader1} became big and shows as heading3 size texts. How do I escape and make sure it only shows Header 1 with heading 1 font and assigned with id of header1?

  2. Refer to internal headings I tried to follow the doc, but still, it only shows the original text with [] and does not turn into clickable links.

Please share some tips and help. Thank you very much.

Upvotes: 2

Views: 3263

Answers (2)

Eri
Eri

Reputation: 90

I know this question was asked a long time ago. Just in case anyone come across this because there is no official docs for this:

You could define your custom anchor to a header using the syntax ## My heading {#my-anchor} and reference it normally with [my text](#my-anchor). This will show the heading correctly as My heading and navigation will work properly.

Upvotes: 0

Chris
Chris

Reputation: 136958

I strongly advise against manually building a table of contents. It's a pain to make them, and even more of a pain to maintain them.

Instead, let software take care of this for you. Here are two GitBook plugins that I just found for making tables of contents:

Plugins can be enabled within the editor or by editing the book.json file.

Upvotes: 1

Related Questions