Links of the form [[#anchor_name]] will link to the first anchor on the page matching that "anchor_name", usually the first identical section heading.
An #anchor_name can also be appended to the page name in any type of link, thus linking to the first identical section heading (or anchor) of the named page:
[[Help:Editing#Links]], [[m:Help:Editing#Links]],
http://meta.wikimedia.org/wiki/Help:Editing#Links
[edit] Automatic anchors
Section headings automatically act as anchors, with the heading text as the "anchor_name". In the case of multiple sections with identical headings, the anchor name of each has "_2", "_3", etc. appended, starting from the second occurrence.
The anchor #toc links to the table of content of the page, unless there is a section titled "toc".
[edit] Manual anchors
Manually-set anchors are useful for linking to "unlinkable" things like a table (title or cell), a section of plain text, etc. For example, in the Wikilink Tricks & Demos table above, though the "Wikilink Tricks & Demos" title-text appears like a (minor) heading, it is not, and the otherwise perfectly normal wikilink [[#Wikilink Tricks & Demos]] will not work.
There are a number of ways to set an anchor at an arbitrary position:
* On some wikis, a template called "anchor" exists, e.g. template:anchor ( talk edit history links ) and w:template:anchor ( talk edit history links ), providing a simple, standardized method for that wiki.
* Generic anchor: some text. For a hidden anchor, omit the text.
* Manual HTML headings (discouraged):
How to Edit
. Text is anchor_name.* In some cases, inserting an HTML-like ID attribute into an (existing) Wiki-element. For example, from the Wikilink Tricks & Demos table above:
!colspan="5" align="left" id="Wiki-link Tricks"|Wikilink Tricks & Demos
* The reserved name [[#top]] always links to the top of a page.
See also Help:Section#Section_linking.
[edit] Linksearch anchors
As mentioned above, if external link style is used, e.g. [10], we can use Special:Linksearch: [11].
Since Linksearch allows specifying the first part of an anchor, it is useful, if anchor names are numerical or have a numerical end, to use leading zeros. Otherwise, when searching for links to e.g. "1", we also get links to "10", etc. This is e.g. applied in w:Portal:Current events/DateHeader2. More generally, if there are anchors "a" and "ab", it may or may not be desired that a search for links to "a" also gives links to "ab"; if not, use an anchor "_a".
[edit] Index-style anchors
If anchor names have multiple components, it is useful to put the most significant component first, e.g. if anchors indicate months or dates, we could have the format YYYY-MM, or YYYY-MM-DD, or in a year page MM-DD (see also [12]), with leading zeros (see also [13]). This applies also for page names, but since these are highly visible, as opposed to anchors, other considerations play a role too. In the case of sections, if for link targets another naming scheme is desired than for display of section headings, explicitly put anchors instead of using section names. This is applied in w:Portal:Current events/DateHeader2, where the use in links of the names of explicitly put anchors is enforced by using pseudo sections, with displayed headings that cannot be used as anchors.
[edit] Anchors in external links (anchorencode)
In an external link, an anchor can be created conveniently with the parser function anchorencode, for example, "{{anchorencode:Anchors in external links (anchorencode)}}" gives "Anchors_in_external_links_.28anchorencode.29" which can be used to form the link http://meta.wikimedia.org/wiki/Link#Anchors_in_external_links_.28anchorencode.29
http://meta.wikimedia.org/wiki/Help:Link#Wiki-link_Tricks
Keine Kommentare:
Kommentar veröffentlichen