Editing
Template:Anchor/doc
From Deskthority Wiki
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS LINKS AT THE END OF THIS PAGE --> The template <nowiki>{{</nowiki>[[{{ns:Template}}:{{BASEPAGENAME}}|{{lc:{{BASEPAGENAME}}}}]]<nowiki>}}</nowiki> inserts one or more [[Wikipedia:Fragment identifier|HTML fragment identifiers]] (anchor names) in a page. Those locations can then be linked to using <code><nowiki>[[#location|β¦]]</nowiki></code> syntax. {{#ifeq:{{BASEPAGENAME}}|Visible anchor| Unlike {{tl|Anchor}}, the first parameter will be visible text on the page.|}} === Examples === 1. <code style="color:darkgreen;">{{{{lc:{{BASEPAGENAME}}}}|Foo<nowiki>}}</nowiki></code> : could be linked to with <tt><nowiki>[[#Foo|β¦]]</nowiki></tt> from within the same article, : or it could be linked to with {{nowrap|<tt><nowiki>[[</nowiki>''<small>Article name</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: :<code>== <span style="color:darkgreen"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|Foo}}</nowiki></span> Section title ==</code> :Here, links via {{nowrap|1=<tt><nowiki>[[</nowiki>''Article name''#Foo<nowiki>]]</nowiki></tt>}} would remain valid even if the section were renamed. See [[#Limitations|Limitations]] for the editing problems this use introduces. :The following is an example of what '''not''' to do: :<code>== Section title <span style="color:darkred"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|Bar}}</nowiki></span> ==</code> :Here, the link {{nowrap|1=<tt><nowiki>[[</nowiki>''Article name''#Bar<nowiki>]]</nowiki></tt>}} would take the user to the section, but could 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, : {{nowrap|1=<code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|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.{{#ifeq:{{BASEPAGENAME}}|Visible anchor| <br /> <br /> 4. If the text to be displayed must differ from the anchor (e.g. because it contains brackets for linking), the <code style="color:darkgreen;">text</code> parameter can be used: : {{nowrap|1=<code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|Foo|text=[[Foo]]}}</nowiki></code>}} : this will result in a link that constitutes an anchor of its own.|}} === Limitations === {|class="wikitable" style="float:right" !Character ![[Wikipedia:Character entity reference|Code]] !Template !Meaning |- |" |<code>&quot;</code> <br /><code>&#34;</code> |N/A |(double) quotation mark |- |# |<code>&#35;</code> |N/A |hash (number) sign |- || |<code>&#124;</code> |{{tl|!}} |Vertical bar |- |= |<code>&#61;</code> |{{tl|{{=}}}} |Equals sign |} * Anchor names that contain any character shown in the table on the right will not work as expected. However, any of these characters can be replaced with the "&#" codes shown for them here. Or, the pipe symbol and equals sign can be worked around with {{tl|!}} and {{tl|{{=}}}}, respectively. Markup code such as <code><nowiki><sup></nowiki></code> and <code><nowiki><sub></nowiki></code> (superscript and subscript) cannot be used. Most other characters, including white space and punctuation, are not a problem. * The template can create a maximum of 10 anchors. Specifying more than 10 anchors will result in an error message. * Unlike with most templates, putting each anchor name on separate lines will not work as expected; for example: :<code style="color:darkred;"><nowiki>{{anchor</nowiki></code> :<code style="color:darkred;">|humpty<br />|dumpty<nowiki>}}</nowiki></code> * Anchor names should be unique on a page, and should not duplicate any heading titles. Duplicate anchors will not work as expected since the <code><nowiki>#location</nowiki></code> links go to the first anchor with that name. Duplicate anchors result in invalid HTML; you can check for duplicate anchors by running the page through the [[Wikipedia:W3C Markup Validation Service|W3C Markup Validation Service]]. * If the template is added to a section title then the code will appear in the edit summary when that section is edited, as in {{nowrap|1="<code><nowiki>/* {{anchor|Issues}}Limitations */ New issue</nowiki></code>"}}. This can be fixed by deleting the template code from the edit summary before the changes are saved. However, this fix breaks the section link in the article revision history. * Anchor links are case sensitive in some browsers, so treat all anchor links as case sensitive. <includeonly> <!-- CATEGORIES AND INTERWIKIS LINKS HERE, THANKS --> [[Category:Other templates]] </includeonly>
Summary:
Please note that all contributions to Deskthority Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Documentation subpage
(
edit
)
Template:Mbox
(
edit
)
Template:Namespace detect
(
edit
)
Template:Nowrap
(
edit
)
Template:Ombox
(
edit
)
Template:Ombox/core
(
edit
)
Template:Tl
(
edit
)
Navigation menu
Page actions
Template
Discussion
Read
Edit source
History
Page actions
Template
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Deskthority forum
Support Deskthority
Search
Main categories
Guides
Keyboards
Keyboard switches
Keycaps
Keyboard modding
Pointing devices
Brands & companies
Group buys
Other topics
Wiki info & links
Recent changes
Random page
All pages
Deskthority wiki help
MediaWiki help
Tools
What links here
Related changes
Special pages
Page information