Linking and page manipulation |
---|
This page explains how to make the wikilink, interwiki link, or external web link (as hyperlinks) connections on Wikipedia, which gives readers one-click access to other Wikipedia pages, other Wikimedia projects, and external websites.
A link has various (changeable) appearances on the "anchor" page, and the "target" page, which owns the "backlinks", and which can count the links to it with the WP:What links here tool.
For a short list of some basic shortcuts, see Wikipedia:Cheatsheet.
For guidelines on how links should be used in Wikipedia, see Wikipedia:Manual of Style/Linking.
A wikilink (or internal link) is a link from one page to another page within the English Wikipedia, or, more generally, within the same Wikipedia (e.g. within the French Wikipedia), in other words: within the same domain, or, even more generally, within the same Wikimedia project (e.g. within Wiktionary).
Links are enclosed in doubled square brackets:
Use a vertical bar "|" (the "pipe" symbol) to create a link which appears as a term other than the name of the target page. Links of this kind are said to be "piped". The first term inside the brackets is the title of the page you would be taken to (the link target), and anything after the vertical bar is what the link looks like for the reader on the original page (the link label). For example:
See Help:Pipe trick for how to generate some common forms of piped links without typing text after the "|".
Letters and other non-punctuation text immediately (i.e. without a space) after the closing brackets of a wikilink becomes part of the label (meaning it is shown in the same colour as the label) without changing the target. This is useful for plurals and verb forms which only add something at the end. For example:
[[apple]]s
generates apples, linking to apple, and is equivalent to but more convenient than[[apple|apples]]
.
This not only saves the active editor time, it also makes the code easier to read; the latter is why it is recommended wherever possible.
More complicated examples:
[[a|b]]c
gives bc, equivalent to[[a|bc]]
.a[[b]]
gives ab. There are no special rules for text preceding a wikilink.- If you want the "a" in front in the colour of the link, you have to write
[[b|ab]]
gives ab. [[a]]:b
gives a:b since the rule doesn't apply to punctuation.
This does the right thing for possessives, like[[Batman]]'s
gives Batman's.[[a]]''b''
gives ab. This rule also applies to "invisible" notation such as double apostrophes (to turn on and off italics)- Even italics in the link:
[[a|a''b'']]
gives ab, but, of course, in colour. [[a]]<nowiki />b
gives ab. The nowiki tag turns off the rule.[[a|b]]<nowiki />c
gives bc.
The link target is case-sensitive except for the first character (so [[atom]]
links to "Atom" but [[ATom]]
does not, it links to a different page).
If the target of a wikilink does not exist, it is displayed in a red color and is called a "red link". Here is a red link example.
To see what the tool tip tells you about a red link and what is displayed at the bottom left corner, move your mouse pointer into this red link.
If a red link is clicked, the user is taken to a blank page where it is possible to create a page using that red linked title. While on that blank page, other red links to this (non-existent) title can be detected using the "What links here" feature.
If the target of a link is the same as the page on which it appears (a self-link), it is displayed in bold font, as with: Help:Link. Yes, its wiki code is actually [[Help:Link]]
. But it is not in the usual link colour, and it does not react as a link does; if the mouse pointer is in it, the mouse pointer looks like being in/over plain text.
When an edit is previewed before saving, if the target of a newly made link turns out to be a disambiguation page, such as the Peacemaker page, the link should be changed to one of the choices on that page unless the link is purposely in a hatnote. If necessary, the new link can be piped, such as in [[Peacemaker (comics)|Peacemaker]]
, which appears as Peacemaker and links to the article about the fictional characters. Readers should not be directed to disambiguation pages unless there is no other option but to do so.
Attempting to link normally to an image page, category page or interlanguage link will produce a different effect: this will respectively place the image on the page, add the page to the category, or create an interlanguage link at the edge of the page. To override this behavior, insert an initial colon ":", as in [[:File:Mediawiki.png]]
, [[:Category:Help]]
, [[:fr:Help:Link]]
.
Less common ways in which link targets are reinterpreted are described below in #Conversion to canonical form.
Inserting and deleting internal links
- When editing source, links are inserted or deleted simply by adding or removing pairs of square brackets enclosing the text concerned (plus handling piped links).
There are some helpful tools:
- When using the visual editor, selecting some text, then clicking the link icon above the text box (two links of a chain) will allow the link to be added, offering a selection of possible matches and the ability to pipe.
- When using the WikEd source editor, selectable from Preferences > Gadgets > Editing, there is a "Wiki link" button (typically the first button on the bottom row). When editing, if some text is highlighted, clicking the Wiki link button will enclose it in double brackets, i.e., Wikilink it. If, however, some text is highlighted that includes one or more internal links—in many cases just a single internal link with its delimiting brackets—they will be removed instead. For a single link without pipe, the Wiki link button will toggle between linking and unlinking.
Interwiki links
An interwiki link links to a page on another Wikimedia project website, such as Meta or another language Wikipedia. The target site must be on the interwiki map specified for the source wiki. These links have the same [[...]] syntax as wikilinks (see previously), but take a prefix ":x:" which specifies the target site.
For example, [[m:Help:Link]]
links to the "Help:Link" page on Meta, while [[:commons:Athens]]
links to page "Athens" on Wikimedia Commons as: commons:Athens.
Interwiki links can be piped, just as with wikilinks. Remember that an interlanguage link should be preceded by a colon if it is to be displayed, where it is inserted in the text, as an inline interlanguage link; otherwise it will be displayed in the list of interlanguage links at the side of the page (which is appropriate only if it is the most closely corresponding page in the other language Wikipedia). Thus (incorporating the pipe trick), [[:ja:Wikilink|]]
would be used to link to Wikilink on Japanese Wikipedia. Example: ([[:ja:URL|]]
links to URL on Japanese Wikipedia).
Interwiki links (like external links) are displayed in a slightly paler blue than ordinary wikilinks. The MediaWiki page formatting does not detect whether these target pages exist, so they are never displayed in red.
External links use URLs to link directly to any web page. External links are enclosed in single square brackets (rather than double brackets as with internal links), with the optional link text separated from the URL by a space (not a "|" as with internal links). When rendered, external links are followed by an external link icon. For example,
[http://www.example.org/ link text]
will be rendered as
The URL must be specified in full, including the protocol: for example [http://...]
or [https://...]
. Short form URLs that are accepted in some other (non-Wikimedia) contexts like [example.org/ link text]
or [www.example.org/ link text]
are not accepted and will not result in a link being generated. Instead, the link generating markup including the square brackets will be copied directly to the marked-up output, thus "[example.org/ link text]" or "[www.example.org/ link text]".
When no link text is specified, external links appear numbered: [http://www.example.org/some-page][http://www.example.org/some-other-page]
becomes [1][2]. Links with no square brackets display in their entirety: http://www.example.org/
displays as http://www.example.org/.
For more detailed information on external linking practices, see Help:URL § Linking to URLs. Also note that Special:LinkSearch can be used to find all pages linking to a given site.
The external link syntax can also be used to link to particular pages within Wikipedia that are not accessible by wikilinks, such as page history, the edit view, an old version of a page, the diff between two versions, etc. It can also be used to create a navigational image.
To display an external link without the arrow icon, place the external link syntax between <span class="plainlinks">...</span>
tags. For instance, <span class="plainlinks">[https:https://www.search.com.vn/wiki/index.php?lang=en&q=Help:Link&action=history this page's history]</span>
will be rendered as: this page's history. If you make frequent use of this, the CharInsert gadget (which can be activated under Preferences → Gadgets → Editing → CharInsert), has an option to insert this text in its "Wiki markup" mode.
In mid-2015, Wikipedia and all other Wikimedia sites were changed to use HTTPS to encrypt all traffic. Accessing a URL like http://en.wikipedia.org/wiki/Help:Link
will result in the webserver redirecting you to https://en.wikipedia.org/wiki/Help:Link
. Therefore, when making an external-style link to an internal page (that is, using single square brackets, or a bare URL), https
should be specified to avoid the needless redirect, as in https:https://www.search.com.vn/wiki/index.php?lang=en&q=Help:Link&action=history
.
In the past, when Wikipedia could be accessed via either HTTP or HTTPS, a protocol-relative URL could be used to make an external link (or external-style link to an internal page) which would use http:
or https:
depending on how the page the link appeared on was accessed, as in [//www.mediawiki.org/wiki/Help:Links]
. However, as all Wikimedia sites now require HTTPS, this linking style is obsolete and should no longer be used. http:
or https:
should be explicitly specified as appropriate for the target site (preferring https:
, where available).
What is an "anchor"?
The word "anchor" has two opposite meanings.
In the context of a link from an anchor to a target, it is the starting place.
In the context of the {{anchor}} template, an "anchor" is a landing place for a link to jump to. The anchor template automatically creates some invisible coding from certain text in the template in the "landing place". In this context, the word "anchor" may refer to:
- the text and parameters, in the template, from which the invisible code is created,
- the mostly invisible HTML code, or
- the landing place/location/spot in itself.
Section linking (anchors)
To link to a section or subsection in another page, append a #
and the section name to the page name:
[[Page name#Section name|displayed text]]
For linking in the same page, omit the page name and use a #
and the section name:
[[#Section name|displayed text]]
Omitting the page name is recommended when linking to a section in the same page because the link will work as expected when previewing changes or after moving the page.
To format a link with the section sign (§) instead of a # (e.g. Page name § Section name rather than Page name#Section name), use the template {{Section link}} (or {{slink}}):
{{Section link|Page name|Section name}}
Note that Section names
are entirely case sensitive, in contrast to article links, where the first letter is not case sensitive.
The characters [ ] { | }
require encoding when linking to a section:
[ | ] | { | | | } |
---|---|---|---|---|
.5B | .5D | .7B | .7C | .7D |
For example, the section "[Closed] Complaint" can be linked with [[#.5BClosed.5D Complaint]]
. Links in the table of contents will automatically make this encoding, so the URL can be copied from there. However, that URL will also encode other characters which do not interfere with templates or wikicode, so the result may look ugly.
For more information, see Help:Section. See also Wikipedia:Redirect § Targeted and untargeted redirects.
Specifics
When a link contains a section title (as in the examples above), the title actually points to an HTML anchor on the target page. In addition to anchors created automatically by section titles, there are times when it's advantageous to create an anchor on a smaller unit of text, such as a specific paragraph (see § Linking to part of a section below). This can be done using {{Anchor|anchor name}}
, or alternatively, the HTML code <span id="anchor name">...</span>
(see {{Anchor}} syntax). Anchors are also used when renaming a section, yet still allowing links to the old name to function, or similarly, allowing linking to a section using an abbreviation; see MOS:HEADINGS for more info. Links to anchors can also be added to external URLs and to interwiki links, again using the #
syntax.
Section links still work through page names that are redirects. For example, if Danzig redirects to Gdańsk, then Danzig#History will link to the "History" section of the article Gdańsk. It is also possible for the target of a redirect to be defined as a specific section or anchor of a page (these work only if JavaScript is enabled). Indeed, according to the Manual of Style, it may be preferable to define such redirects, and use them when linking to those sections/anchors, rather than linking using the [[Page name#Section or anchor name|displayed text]]
or {{Section link|Page name|Section name}}
syntax. This way, if the section or anchored text later becomes its own article, links via the redirect won't need to be rewritten.
For example, Wikipedia:Section link redirects specifically to the section Help:Link#Section linking (anchors) on this page. A quirk of the way this works is that if one were to add a section name when using such a link, it would override the section specified by the redirect. So Wikipedia:Section link#Interwiki links would go to the "Interwiki links" section of this page. Such overriding of section redirects should be avoided.
The {{Visible anchor}} template can be used to create an anchor associated with text that is highlighted when the anchor is linked to (example - click here). The template's first parameter will be used as both the anchor and the display text (|text=
can be used to provide different display text).