zola/docs/content/documentation/content/linking.md
Vincent Prouillet bdcad38310 Finishing up site (#131)
* Finishing up site

* Make site a bit responsive

* Fix menu responsiveness

* Remove Fira Sans and revamp a bit text

* Update list of syntax and change output of syntax

* Add Rust mention

* Some doc tweaks

* Correct capitalization for GitHub

Correct capitalization for GitHub

* Some CSS tweaks

* More css tweaks + favicon

* Add link to my site
2017-10-19 13:48:50 +02:00

1.6 KiB

+++ title = "Internal links & deep linking" weight = 50 +++

Header id and anchor insertion

While rendering the markdown content, a unique id will automatically be assigned to each header. This id is created by converting the header text to a slug, appending numbers at the end if the slug already exists for that article. For example:

# Something exciting! <- something-exciting
## Example code <- example-code

# Something else <- something-else
## Example code <- example-code-1

Anchor insertion

It is possible to have Gutenberg automatically insert anchor links next to the header, as you can see on the site you are currently reading if you hover a title.

This option is set at the section level: the insert_anchor_links variable on the Section front-matter page.

The default template is very basic and will need CSS tweaks in your project to look decent. If you want to change the anchor template, it can easily be overwritten by creating a anchor-link.html file in the templates directory.

Linking to other pages and their headers is so common that Gutenberg adds a special syntax to Markdown links to handle them: start the link with ./ and point to the .md file you want to link to. The path to the file starts from the content directory.

For example, linking to a file located at content/pages/about.md would be [my link](./pages/about.md). You can still link to a header directly: [my link](./pages/about.md#example) will work as expected.