Template:Anchor: Difference between revisions

From Wikipedia of the Dark Brotherhood, an online Star Wars Club
(Allows you to add anchors outside of using headings.)
 
(The source and documentation from this is ripped off from wikiprime.)
 
Line 13: Line 13:


<noinclude>
<noinclude>
The template <nowiki>{{anchor}}</nowiki> inserts one or more HTML anchors in a page. Those locations can then be linked to using <nowiki>[[#link|...]]</nowiki> syntax.
Examples
1. <nowiki>{{anchor|foo}}</nowiki>
    could be linked to with <nowiki>[[#foo|...]]</nowiki> from within the same article,
    or it could be linked to with <nowiki>[[articlename#foo|...]]</nowiki> from other
    articles and from redirects.
2. Anchors can be more suitable for inter-article linking than section titles are. For example,
    <nowiki>== {{anchor|foo}} Section title ==</nowiki>
    Here, links via <nowiki>[[articlename#foo]]</nowiki> would remain valid even if the section were renamed.
3. The template can be used to create up to ten anchors with a single call. For example,
    <nowiki>{{anchor|foo|bar|baz}}</nowiki>
    will create three anchors that can then be linked to with <nowiki>[[#foo]]</nowiki>, <nowiki>[[#bar]]</nowiki> and <nowiki>[[#baz]]</nowiki>.
    Specifying more than 10 anchors will cause an error message to be displayed.
[[Category:Utility templates]]
[[Category:Utility templates]]
</noinclude>
</noinclude>

Latest revision as of 10:18, 27 December 2012



The template {{anchor}} inserts one or more HTML anchors in a page. Those locations can then be linked to using [[#link|...]] syntax. Examples

1. {{anchor|foo}}

   could be linked to with [[#foo|...]] from within the same article,
   or it could be linked to with [[articlename#foo|...]] from other
   articles and from redirects.

2. Anchors can be more suitable for inter-article linking than section titles are. For example,

   == {{anchor|foo}} Section title ==
   Here, links via [[articlename#foo]] would remain valid even if the section were renamed.

3. The template can be used to create up to ten anchors with a single call. For example,

   {{anchor|foo|bar|baz}}
   will create three anchors that can then be linked to with [[#foo]], [[#bar]] and [[#baz]].
   Specifying more than 10 anchors will cause an error message to be displayed.