Template:MC/Anchor/doc
More actions
Template:Documentation header Template:Shortcut This template can be used to allow linking to a section of an article without the creation of headers. Common use cases include use within larger tables and after renaming a section.
Usage
If {{anchor|Example}} is placed on the next line, then Template:Anchor#Example will link to that line.
For example, this code: <syntaxhighlight lang=wikitext> Template:Anchor Example anchor sentence. </syntaxhighlight> Produces:
- Template:Anchor Example anchor sentence.
This template supports multiple parameters as well. So {{anchor|Example|Anchor|Test}} will create anchors "Example", "Anchor", and "Test" at the place of its usage.
Only thirteen anchors are supported in one call of the template, if you need any more, you will need to call a second instance of the template.
Multiple section heading anchors
This template can also be used for adding another anchor to a section heading, for example:
<syntaxhighlight lang=wikitext>
{{subst:anchor|Heading alias}} Heading
This is a content. </syntaxhighlight>
The code above creates "Heading alias" anchor precisely at "Heading" section. This enables editors linking either "Heading alias" or "Heading" to that section. This is useful when renaming a section heading, as the previous name might still be used for linking on other pages, and adding an anchor for it keeps the previous links working.
Remember to substitute correctly as to not cause any technical problems (see WP:ANCHORSUBST).
To add more anchor in the future, you may add the template after the span tag used to add the anchor:
<syntaxhighlight lang=wikitext>
{{subst:anchor|Another alias}} Heading
This is a content. </syntaxhighlight>
This is equivalent to <syntaxhighlight lang=wikitext inline>{{subst:anchor|Headling alias|Another alias}}</syntaxhighlight>.
See also
- {{visible anchor}}, which shows the parameter as text
- {{section link}}, which generates a link to a specific section of a page
cs:Šablona:Anchor/doc de:Vorlage:Anker/Dokumentation es:Plantilla:Anchor/doc fr:Modèle:Anchor/doc nl:Sjabloon:Anchor/doc pt:Predefinição:Âncora/doc ru:Шаблон:Якорь/док th:แม่แบบ:Anchor/doc uk:Шаблон:Якір/док zh:Template:Anchor/doc