diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md index 5fabce8b7..8500f602a 100644 --- a/STYLE_GUIDE.md +++ b/STYLE_GUIDE.md @@ -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.