Template:Anchor


Syntax

This templates does NOT use parameters. Calls templates: (none).
Sets commands: (none).
What links here?

Usage

{{Anchor}} will insert one or more HTML anchors in a page at the location of its invocation, enabling direct #Links to this location.

Example

{{anchor|SpanIDname1|SpanIDname2}}

Notes

  • The template will handle up to 10 anchor names, but could very easily be extended to do twice or more. If you accidentally use more than 10 anchors, the template will output an error message in a yellow box like this:
    Template:Anchor: too many anchors
    This will let you know about it instead of having your extra anchors silently ignored.
  • When used to add anchors to a paragraph of prose, it is preferable to put the template at the very start of the paragraph (stuck to the first word, without space) so as to ensure that incoming #Links will result in the full paragraph being displayed on the reader's screen.
  • You can add anchors aliases to a heading by using a syntax such as:
==Heading title {{Anchors|Foo|Bar & Baz}}==
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.
  • It is better however to add anchors after the heading on the next line, for the anchors in a section title echo inside any section edit summary and work just as well.
==Heading title==
{{Anchors|Foo|Bar & Baz}}
 <!-- this blank line recommended, the browser will then position 
      vertically aligned to the heading -->
Next text line...
  • Inside a heading, 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, but 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.

Contact the Khaos Team