Template:W/doc
Documentation
This template provides a convenient way of linking to or citing an article (or any other page) at Wikipedia.
It exists mainly to:
- save a little typing in the simplest cases (compare:
[[wikipedia:Norway|Norway]]vs.{{w|Norway}}); - make it easier to find pages on which such links are used, via the "WhatLinksHere" feature (as there is no way to find interwiki links with a search);
- provide a distinct way of indicating that such links leave the wiki (by default, interwiki links are not styled like external links); and
- provide a quick way to cite Wikipedia as a reference.
The template does not complain about missing input; instead it uses the name of the page calling the template as the link target if no Wikipedia article title is specified (as seen above — note that the name of this template page is "W").
The name of the template is, of course, based on the word "Wikipedia".
Usage
Common forms (other combinations are possible):
{{w|Article Title}}{{w|Article Title|linked text}}{{w|Article Title|linked text|accessed=access date}}{{w|lang=code|Article Title}}{{w|lang=code|Article Title|site=site name if not Wikipedia}}{{w|Article Title|encl=char}}{{w|Article Title|open=char|close=char}}
Note that "Article Title" here refers to the title of an article at Wikipedia, not the title of the wiki article in which the template call is used. And char stands for "character", although these parameter values do not actually need to be single characters (but they usually are).
When used with the accessed parameter, the template acts more like a citation template, as seen in the examples below.
There is no significance to the lang parameter appearing before the Wikipedia article title (the first unnamed parameter) in the third and fourth forms above, except that this mirrors the way interwiki links are formed (e.g., {{w|lang=no|Norske Talenter}} is equivalent to [[wikipedia:no:Norske Talenter|Norske Talenter]]). Note that the value specified for the lang parameter must not end with a colon, because the colon is already provided by the template itself. This value must be the subdomain of the non-English Wikipedia you want to link to — i.e., the part of the URL before .wikipedia.org (see examples below).
The encl [referring to "enclosure" or "enclosing character(s)"] and open/close parameters can be used for quotation marks and the like, so these things will appear before the little "leaving the wiki" indicator but outside of the link itself (see examples below). Any combination of these three parameters can be used together (for example, you could use encl and close without open, if that's necessary for some reason).
All parameters
{{w|lang=|||site=|encl=|open=|close=|pre=|post=|accessed=}}
Examples
{{w|Willie Nelson}}⇒ Willie Nelson↗{{w|Gloomy Sunday|encl="}}⇒ "Gloomy Sunday"↗{{w|Gloomy Sunday|encl="|accessed=2020-10-23}}⇒ "Gloomy Sunday"↗. Wikipedia. Accessed 2020-10-23.{{w|Norway's Got Talent|encl=''}}⇒ Norway's Got Talent↗{{w|lang=no|Norske Talenter|open=«|close=»}}⇒ «Norske Talenter»↗{{w|lang=no|Norske Talenter|encl="|open=«|close=»|pre=¿|post=?}}⇒ ¿"«Norske Talenter»"?↗{{w|All of Me (John Legend song)|All of Me|encl="}}⇒ "All of Me"↗{{w|wikt:acronym|acronym|site=Wiktionary}}⇒ acronym↗
The fifth example is there just for "completeness", to show the order of the encl, open/close, and pre/post parameters, when used together.
The last example shows how Wikipedia's interwiki linking feature can be taken advantage of to link to other sites. In this case, the same thing could be accomplished more "cleanly" using {{iw}}:
{{iw|wikt|acronym|site=Wiktionary}}⇒ acronym↗
Using quotation marks directly
Trying to use quotation marks in or around the template call (without using the encl parameter) doesn't really work too well:
"{{w|Gloomy Sunday}}"⇒ "Gloomy Sunday↗"{{w|"Gloomy Sunday"}}⇒ "Gloomy Sunday"↗{{w|Gloomy Sunday|"Gloomy Sunday"}}⇒ "Gloomy Sunday"↗"[//en.wikipedia.org/wiki/Gloomy_Sunday Gloomy Sunday]"⇒ "Gloomy Sunday"[//en.wikipedia.org/wiki/Gloomy_Sunday "Gloomy Sunday"]⇒ "Gloomy Sunday"
These last two examples use external links, just for comparison.
The link in the second example is broken at Wikipedia (the relevant article there does not have quotation marks). The first and fourth just look weird. The third and fifth look and work fine, but are tedious to implement (and a bit error-prone).
See also
Templates for interwiki linking: [edit this list]
These call the following:
{{iw}}– generates an interwiki link