Template:Anchor/doc: Difference between revisions

From Path of Exile 2 Wiki
Jump to navigation Jump to search
(Created page with "{{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> The template {{tl|anchor}} inserts one or more [[Wikipedia:HTML element#Anc...")
 
m (11 revisions imported)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->


The template {{tl|anchor}} inserts one or more [[Wikipedia:HTML element#Anchor|HTML anchor]]s in a page. Those locations can then be linked to using <code><nowiki>[[#link|...]]</nowiki></code> syntax.
{{Lua|Module:Anchor}}


==Usage==
{{Adapted from Wikipedia|Template:Anchor}}
1. <code style="color:green;"><nowiki>{{anchor|foo}}</nowiki></code>
: could be linked to with <tt><nowiki>[[#foo|...]]</nowiki></tt> from within the same article,
: or it could be linked to with <tt><nowiki>[[</nowiki>''<small>articlename</small>''#foo|...<nowiki>]]</nowiki></tt> from other articles and from redirects.


2. Anchors can be more suitable for inter-article linking than section titles are. For example,
{{Documentation categories|
: <code style="color:gray;"><nowiki>==</nowiki></code> <code style="color:green;"><nowiki>{{anchor|foo}}</nowiki></code> <code style="color:gray;">Section title <nowiki>==</nowiki></code>
<!-- Categories and interwikis go here. -->
: Here, links via <tt><nowiki>[[</nowiki>''articlename''#foo<nowiki>]]</nowiki></tt> would remain valid even if the section were renamed. Consider using {{tlsp|anchor comment}} beneath the section title to generate an HTML comment alerting other editors to the purpose of anchors used in this manner.
[[Category:Link formatting templates]]
 
}}
: The following is an example of what '''not''' to do:
: <code style="color:gray;"><nowiki>==</nowiki> Section title</code> <code style="color:green;"><nowiki>{{anchor|bar}}</nowiki></code> <code style="color:gray;"><nowiki>==</nowiki></code>
: Here, the link <tt><nowiki>[[</nowiki>''articlename''#bar<nowiki>]]</nowiki></tt> would take the user to the section, but undesirably hide the section title from view.
 
3. The template can be used to create up to ten anchors with a single call. For example,
: <code style="color:green;"><nowiki>{{anchor|foo|bar|baz}}</nowiki></code>
: will create three anchors that can then be linked to with <tt><nowiki>[[#foo]]</nowiki></tt>, <tt><nowiki>[[#bar]]</nowiki></tt> and <tt><nowiki>[[#baz]]</nowiki></tt>.
: Specifying more than 10 anchors will cause an error message to be displayed.
 
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:Templates|{{PAGENAME}}]]
</includeonly>

Latest revision as of 16:11, 23 September 2024

This subpage provides documentation for Template:Anchor.

Lua logo

This template uses the following modules:

This template was adapted from Template:Anchor on Wikipedia.
Adaptation is noted for reference and attribution only. This template may differ from the original in function or in usage. The documentation on Wikipedia may be helpful in understanding this template.