Difference between revisions of "Template:Anchor/doc"
m |
Thcipriani (talk | contribs) m (1 revision imported) |
(No difference)
|
Latest revision as of 20:51, 14 May 2016
{{#ifeq:doc|{{#ifeq:|override|doc|doc}}|{{#invoke:Fallback | autotranslate
|base = Documentation subpage |lang = |page = {{#if:||Template:Anchor}} }}}}
This template manually adds one or more HTML anchors (i.e., link targets) to a page. This allows incoming links to target locations on the page other than section headings.
Usage
{{anchor|target}}
{{anchor|target|Target|TARGET}}
This allows links of the form [[#target]]
to be used on the same page and links of the form [[Page title#target]]
to be used on a different page (assuming "Page title" is the title of the page this template is used on).
The second example usage shows how multiple anchors can be provided within a single template call. It also illustrates how capitalization differences are significant in HTML anchor names; for this reason, if you suspect that incoming links will try to use targets with different capitalization (or punctuation, whitespace, etc.), then all allowed forms must be explicitly listed in the template call.
However the main reason you'll want to insert anchors is in section headings that may be translated: you'll want to create anchors that work across languages when the source language is not predictable; the other reason is that distinct sections may have identical headings and you cannot link to the correct one distinctly. In such cases, you'll want to create unique symbolic anchors specific to each section of the page, but independant of its translations, and a single anchor should generally be sufficient.
You may want still want to create additional anchors for joining anchors related to different keyword to the same section of text in your page (for example in a glossary page where related terms are defined in the same paragraph), you'll create as many anchors as there are terms that may be referenced.
Limitations
Up to 10 targets can be specified in a single template call, otherwise an error message will be displayed (this message may break the page layout) and the current page will be listed in the error-tracking Category:Template:Anchor/too many anchors (this maintenance category should remain empty and does not need to be created). If more anchors are are needed, a second template call can immediately follow the first one.
See w:Template:Anchor for more information, including limitations on valid target names.