Chapter 1
Internal Links
Internal Links are hypertext links from one article...
...to a heading using heading name within the same gitbook
...to a heading using a custom name within the same gitbook
...to another article within the same gitbook
Internal Links come in two flavors:
Relative internal links
- "Relative" refers to the fact that the links are relative to the folder structure you build for your gitbook (in the "Files Tree" of the online editor or a local folder structure).
HTML internal links
- "HTML" refers to each link being a URL with online usage only. These links cannot be used for offline reading of PDF's.
Examples:
Link to article heading using heading name:
Relative Internal Link to a heading in the SAME article:
Syntax:
[heading](#test)
Format:
[link text](#<heading-name>)
Relative Internal Link to a heading in ANOTHER article: (notice the "../")
NOTE: This syntax links to the appropriate anchor tag for a split second, then takes me to the top of the article.
Syntax:
[heading](../chapter2/test.md#h5)
Format:
[link text](../<chapter>/<article>.md#<heading-name>)
HTML Internal Link to a heading in the SAME article:
Syntax:
[heading](https://seadude.gitbooks.io/linking/content/chapter1/internal.html#test)
Format:
[link text](https://<username>.gitbooks.io/<bookname>/content/<chapter>/<article>.html#<heading-name>)
HTML Internal Link to a heading in ANOTHER article:
Syntax:
[heading](https://seadude.gitbooks.io/linking/content/chapter2/test.html#h5)
Format:
[link text](https://<username>.gitbooks.io/<bookname>/content/<chapter>/<article>.html#<heading-name>)
Link to article heading using custom name:
Link to custom header in SAME article:
Syntax:
[custom header](#test-me)
Format:
[link text](#<anchor-tag>)
Link to custom header in the SAME gitbook:
Syntax:
[custom header](../chapter2/external.md#random-tag)
Format:
[link text](../<chapter>/<article>.md#<heading-name>)
Whats the difference?
The relative link (to the .md file) works in both PDF and the online editor.
- Download the PDF of this Gitbook to try!
The HTML link is better suited for the online editor.
Link to article:
Relative Internal Link to an article in the SAME gitbook:
Syntax:
[article](../chapter2/external.md)
Format:
[link text](../<chapter>/<article>.md)
HTML Internal Link to a article in the SAME gitbook:
Syntax:
[article](https://seadude.gitbooks.io/linking/content/chapter2/external.html)
Format:
[link text](https://<username>.gitbooks.io/<bookname>/content/<chapter>/<article>.html#<heading-name>)
Link from Subchapter Article to Subchapter Article:
(Believe it or not...It's a different syntax!)
Relative Internal Link from Subchapter to another Subchapter. First, visit this link to get to a subchapter
Syntax:
[visit this link](../chapter2/test.md#get-there)
Format:
(../<chapter>/<article>.md#heading)
Drag And Drop Links!!:
Can you believe it! The awesome folks at Gitbook has WYSIWYG'd the UI. You can now drag and drop links to images and (after a bit of cleanup) articles right into your book.
To drag and drop images:
- Drag image into gitbook
- By default, gitbook places your image at the root of the book
- Right click, "Rename" and add a subfolder if you wish
- Open subfolder, then just drag into your gitbook!
- Easy peasy
Important:
Naming conventions:
- Be careful with how you name and build your SUMMARY.md
Headings:
You can link to H1-H5 headings by using a single "#" in the link syntax
Heading syntax must be all lower case, spaces converted to "-" (dashes).
PDF:
- Internal Links that end in a folder name
[link](../chapter)
, links ending in.html
, or.html#heading
will not work in PDF. - The only links that work in PDF are to link to the original
.md
versions of files
- Internal Links that end in a folder name
Root directory README.md file:
Your root "README.md" file will render to "index.html" when converted by Gitbook to a static site.
If linking TO and FROM your root README.md file, you will need alter your link syntax as follows:
Linking to root README.md file:
Syntax:
[README.md](/README.md/#test)
Format:
[link text](/README.md)
Link from root README.md file to "Important" heading in this chapter:
Syntax:
[Chapter 1](/chapter1/internal.md#important)
Format:
[link text](/<chapter>/<article>.md#<header-name>)
Test
Test HTML Anchored Heading
Syntax:
# Test HTML Anchored Heading {#test-me}
PREVIOUSLY TRIED BOTH OF THESE, NEITHER WORK
# Test HTML Anchored Heading <a name="test-me"></a> <!--previous--> # <a name="test-me">Test HTML Anchored Heading</a> <!--current-->
- Format:
# Heading Name {#anchor-name}