Making an anchor to another heading in the same file as the anchor is straightforward.
[The header of this page](#same-file-anchors-for-github)
Will show as The header of this page.
The heading should be downcased, spaces changed to hyphens, and removed anything not a letter, hyphen, or space. If this id is not unique, you add "-1", "-2", and so forth to the header.
Examples:
# Some HEADER
Becomes
(#some-header)
# New-header2
Becomes
(#new-header)
Caution
Read comment by @karlhorky as this method currently doesn't work
If you are working with Github Pages and want to make a header to another file you simply add filename.md
in front of the header's link.
So if we had to reference a file in the same directory named github-tips.md
with a header called # Anchors
we would simply write (github-tips.md#anchors)
.
Like with a normal command-line folder navigation, you can use /
go into a folder and ../
to go out of a folder.
See the following example:
. ├── folder 1 │ ├── first.md │ ├── second │ │ └── fileInSecond.md │ └── main.md └── outer.md
Placing links inside main.md
will look like:
[first](first.md) [file in folder](second/fileInSecond.md) [outer](../outer.md)
These links inspired this Gist, and will also provide in-depth information, hopefully answering any further questions.
Thanks to @asabaylus and @TomOnTime for the same-file anchors. Thanks to @uranusjr for the cross-file anchors.
👍