Template:Anchor/doc

Usage
Anchor, or its plural Anchors, will insert one or more in a page at the location of its invocation, enabling direct #Links to this location.

Linking
After adding the Anchor template to a page, you can have links sent directly to the line you marked:


 * With
 * With
 * With
 * With
 * With
 * With

Usage details

 * Code


 * yields
 * BeforeAfter

The template also works for adding aliases directly inside a heading:


 * Code


 * yields
 * (see heading below)

Heading title

 * This results in "#Foo" and "#Bar & Baz" being alias targets of "#Heading title" which may be subject to change. Anchors are a way to keep links "healthy" despite such local changes.  This syntax doesn't alter the heading, which remains a regular heading as functional as if the template wasn't inserted (i.e. still appears in the page's TOC, and section editing works as usual).  This method is advantageous in that you can always see the anchors list when editing this section only, and they work exactly like the heading's own regular anchor. (This is not the case when the anchors are added one line above or below the heading.

Heading title
Next text line...
 * Inserting the anchor code before or after the actual heading title works mostly the same. Putting it before the heading makes it work more like an actual heading anchor in more web browsers, but putting it after the heading makes the regular heading more readable and easy to find.  Having a space between the template and the heading title is inconsequential; adding a space keeps it more readable, but does impact the length of section edit titles.
 * Even when you have many long aliases, you need to keep the heading and its embedded anchors on a single line (which may be very long and wrap), as its own single paragraph. Trying to use a vertical format for the template would give all the appearances of working, including section numbering, but actually trying to edit the section results in editing the next section instead, due to a bug.  So, in headings, do not use a vertical format such as:

== George Walker Bush ==

Known bug

 * Currently, as noted above, the anchor code is included in a section-edit summary. For instance, section-editing the "Notes" section of this page will pre-fill your edit summary with:
 * This is inconsequential for your edit, but can be inconvenient for your edit summary when there are many long anchor names. You can however edit it out to just:
 * This bug can't be helped in the template itself. It is hoped, not promised, that a future version of the MediaWiki software will skip template calls in headings for section-edit summaries.
 * This bug can't be helped in the template itself. It is hoped, not promised, that a future version of the MediaWiki software will skip template calls in headings for section-edit summaries.
 * This bug can't be helped in the template itself. It is hoped, not promised, that a future version of the MediaWiki software will skip template calls in headings for section-edit summaries.

Tips

 * When you make a link from article A to article B#Heading, you can preemptively edit article B from
 * To:
 * (This will ensure the continued functioning of any link to #Heading, regardless of how the actual heading may be changed in the future. Since you can't expect other editors to mind your target anchors, this solution is more efficient and proactive than just adding an HTML comment "this heading is linked from article A" next to the heading.  Such a comment is still a good idea though – most editors will have no clue as to what an Anchor is or does.  The comment makes the link existence, dependency, and need plain.
 * (This will ensure the continued functioning of any link to #Heading, regardless of how the actual heading may be changed in the future. Since you can't expect other editors to mind your target anchors, this solution is more efficient and proactive than just adding an HTML comment "this heading is linked from article A" next to the heading.  Such a comment is still a good idea though – most editors will have no clue as to what an Anchor is or does.  The comment makes the link existence, dependency, and need plain.
 * (This will ensure the continued functioning of any link to #Heading, regardless of how the actual heading may be changed in the future. Since you can't expect other editors to mind your target anchors, this solution is more efficient and proactive than just adding an HTML comment "this heading is linked from article A" next to the heading.  Such a comment is still a good idea though – most editors will have no clue as to what an Anchor is or does.  The comment makes the link existence, dependency, and need plain.


 * Similarly, when you add an anchor alias to a heading, you can preemptively add a copy-paste of the current heading's title along with your new anchor. For instance, for adding a "#Regions" anchor to this heading:
 * You would make it:
 * This too will ensure the longevity of both " " and " ", regardless of other editors' future edits on the heading.
 * This too will ensure the longevity of both " " and " ", regardless of other editors' future edits on the heading.
 * This too will ensure the longevity of both " " and " ", regardless of other editors' future edits on the heading.

Anchor names

 * Due to technical limitations, anchor names can not include the characters "#" (hash), "&#124;" (pipe) or "=" (equal). On the other hand, special characters such as " " (space), "," (comma), "&" (ampersand), etc. can be used directly both in anchors and links, because the software will process them automatically into a URL-compatible format.
 * Anchor names should be unique (with respect to all heading titles and additional anchors) on each page; a duplicate anchor won't work since the   will always go to the first homonymous anchor on the page.

Technical

 * The template is based on