Skip to content

Commit

Permalink
Add info re links
Browse files Browse the repository at this point in the history
  • Loading branch information
orbsmiv committed Oct 30, 2022
1 parent bf27342 commit 2c50ce3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,36 @@ For example:

!!! note
This is a note.
```

## Internal Links

MkDocs automatically adds an html anchor to all headers. The default anchor is the header text in lower case and spaces replaced by `-`. So, the header 'Internal Links' gets an automatic anchor of `internal-links`. (Note too that multiple `-` characters, e.g. `--robot`, in a header will be truncated to a single `-` in the anchor.)

We can manually specify the anchor by adding an attribute, so:

``` markdown
## Internal Links {: #anchor }
```

The standard MkDocs method to link to another page is by reference to the relative path to the markdown file:

``` markdown
[link text](page.md)
```

and to a section within the page with

``` markdown
[link text](page.md#anchor)
```

The EasyBuild docs uses [mkdocs-autorefs](https://github.com/mkdocstrings/autorefs). This allows internal links to be automatically linked by referring only to the anchor, e.g.

``` markdown
[link text][anchor]
```

N.B. according to the *mkdocs-autorefs* README:

> Note that this plugin's behavior is undefined when trying to link to a heading title that appears several times throughout the site. Currently it arbitrarily chooses one of the pages.

0 comments on commit 2c50ce3

Please sign in to comment.