↑ arvau

Wikipedia / Help:Link

This page explains how to make links to pages on Wikipedia (wikilinks), to other Wikimedia projects (interwiki links), and to other websites (external links). It also explains how to make anchors within Wikipedia pages. For guidelines on how to use links, see Wikipedia:Manual of Style/Linking.

A "wikilink" is our common name for an internal link, that is, a link from one page to another page within the Wikipedia (for example, within the French Wikipedia) or within the same Wikimedia project (for example, within Wiktionary).

Basic syntax

A wikilink is enclosed in double square brackets.

On any Wikimedia page, produces a wikilink with the display text Example and the target page Example on the project you're currently on. For instance, here on the English Wikipedia, the wikilink would lead to the following URL (note the "en" in the address):

Section linking

To link to a section in another page, append a hash mark, pound or number sign (#) followed by the section name to the page name:

Note the use of piping, done to hide the character. This is appropriate in Wikipedia articles.

Alternatively, format such section links with the section sign () instead of a by using the template (alias ):

Note: you cannot use the directly.

That is, use section link or rather than Page name#Section name. A third option is to use a redirect (link to a page which link directly to a section, see MOS:SECTLINK).

Outside of article space, such as in talk page discussions, using the raw syntax is fine. Wikipedia inherits this syntax from HTML.

These section links work the same regardless of nesting, i.e. whether you link to a section header, a subsection header or a sub-subsection header (sections nestled inside other sections):

Note that this means that each header title must be unique across the entire page (or your browser will simply link to the first one encountered). You do not and cannot indicate "a section within a section" doesn't work as intended.

To link to a section on the page you're already on, you may omit the page name:

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. It also makes it clear you intend a same-page link.

Note that section names are entirely case sensitive, in contrast to article links, where the first letter is not case sensitive.

The characters [ ] { } | (right and left square bracket, right and left curly braces, and the vertical bar of a link. See note.

For more information, see Help:Section. See also .

Alternate display text

Use a vertical bar (the "pipe" symbol) to create a link with different display text than the name of the target page. Such a link is called a piped link. Within the link brackets , the part preceding the pipe gives the actual title of the link target page, and the part following the pipe gives the link display text:

  1. appears on the page as b, but, when opened, links to page a:

Display text agglutination

Letters and other non-punctuation characters immediately following the closing bracket of a wikilink — with no whitespace in between — get appended to the link display text. The target is unchanged. This syntax provides a shorthand to link to an article by its canonical title while displaying inflected link text that grammatically agrees with the inline text:

  1. "There are over 7,500 known cultivars of apples."

gives the display text apples but the target page apple. This shorthand syntax is equivalent to .

Illustrative examples of display text agglutination
  • gives bcc, equivalent to .

  • gives ab.There are no special rules for text preceding a wikilink.

  • To prepend preceding text to a displayed link: gives ab.

  • gives a:b.Punctuation breaks display text agglutination. This is often helpful for possessives: for example, gives Batman's.

  • gives ab.Markup notation — for example, italics delimited by two sequential single quote characters — is also considered punctuation despite not being rendered as such. As a result, italic text immediately following the wikilink is not included in the displayed link.

  • To append italicized text to a displayed link: gives ab.

  • gives ab.The nowiki tag turns off the rule.

  • gives bc.

Target page

When a wikilink is opened, Wikipedia tries to resolve the Wikilink target title to its canonical target page. See

When resolving the target page, the target title is treated as case-sensitive except for the first character:

Disambiguation

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 pipedd, such as in , 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.

If the target page of a wikilink does not exist, it is displayed in red font and is called a "red link":

This link is an example of a red link

On hover over the red link, a tool tip provides more information about the red link.

If a red link is opened, 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.

A self link is a wikilink with a target page identical to the page on which it appears. Instead of producing an actual link, self links behave like regular body text, with no action upon interaction, and are rendered as bolded body text: is a self link to this page, so it appears on this page as Help:Link and has no action upon interaction. This is also true for piped self links: . However, with the preference setting "Link underlining", the bolded text is underlined; this can be suppressed by putting the following in your relevant personal CSS page:Bolded self-links are usually undesirable, except within navigation templates, where the self-link-produced boldface helps locate the article within the template. In some cases, such as with templates that are not navigation templates, and that are transcluded into several pages, self-links can be actively suppressed by enclosing the link within the template .

A link to a section of the same article, even from the same section, does not produce bold text and works as a normal link. For example, . Such section links should usually be written without the page name (), because this method does not cause the page to reload if the reader initially arrived at the page via a redirect, and is thus more efficient. A useful application is links from article leads or overview sections to detail sections buried deeper in the same article. An automatically generated table of contents has links to sections on the page.

A self-link is indirect if it links to a page that redirects back. In this case, the page name is technically different, so the link is not bolded: . If the link contains the prefix for the same project, the self-link feature works as intended: .

Some types of wikilink target pages result in special behavior:

  • renders the linked image on the current page.

  • adds the current page to the linked category.

  • creates a meta interlanguage link to the same article within a different language Wikipedia.

When targeting these page types, the special behavior can be suppressed to display a regular wikilink by prepending a colon character to the target page:

Less common ways in which link targets are reinterpreted are described below in #Conversion to canonical form.

Editing tools

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 a pipe, the Wiki link button will toggle between linking and unlinking.

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 syntax as wikilinks (see previously), but take a prefix ":x:" which specifies the target site.

For example, links to the "Help:Link" page on Meta, while 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), would be used to link to Wikilink on the Japanese Wikipedia. Example: ( 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,

will be rendered as

  1. link text.

The URL must be specified in full, including the protocol: for example or . Short form URLs that are accepted in some other (non-Wikimedia) contexts like or .

When no link text is specified, external links appear numbered: becomes http://www.example.org/some-pagehttp://www.example.org/some-other-page. Links with no square brackets display in their entirety: displays as http://www.example.org/.

For more detailed information on external linking practices, see . 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 tags. For instance, , or its template equivalent , will be rendered as: this page's history. If you make frequent use of this, the CharInsert gadget (which can be activated under ) has an option to insert this text in its "Wiki markup" mode.

http: and https:

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 http. 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://en.wikipedia.org/w/index.php?title=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 . 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).

Anchors

What is an "anchor"?

A link from an origin page points to either a whole target page or to a particular spot on a target page. An "anchor" is the computer code that marks a destination spot on a target page. A link to an anchor is sometimes referred to as an "anchor link".

Wikipedia automatically creates an anchor for each section and subsection heading. As discussed below, editors may also create anchors anywhere on a target page using HTML code or the template. Renaming a section or subsection changes its automatic anchor, leaving no target for pre-existing anchor links that use the old name. To preserve the old target, editors often create an anchor using the old heading name.

Section anchors

A link to a section title (as in the examples above) points to an HTML anchor that Wikipedia automatically generates on the target page. Editors can create anchors on smaller units of text using the template or the HTML code .

Editors create anchors to

  • target a specific paragraph (see below),

  • rename a section while still allowing links to the old name to function, or

  • link 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 or 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#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 template can be used to create (click here for an example). The template's first parameter will be used as both the anchor and the display text ( can be used to provide different display text).

Accessibility

If the target of the anchor is a section, the anchor should always be placed the section header to the left of the section header text. If the template is used, it should always be . Not doing so violates and and causes technical complications and accessibility issues. See this documentation page for more information.

Duplicate section names

If more than one section on a target page has the same title, a link to the title goes to the section with that title. If the link should be to another section with the title, or a title that differs only in capitalization (Example vs. EXAMPLE), append to the linked title _2, _3, and so on, without a space (or 2, 3, and so on a space), counting from the top of the target page and without regard to whether a section is a top-level section or a subsection. For example, multiple sections titled "History" may be linked to as "History", "History_2" (or "History 2"), and so on.

Linking to part of a section

Anchors can also be used to link to any part of a section. For example, if you want to link to the fifth sentence of a section, you place an anchor at the start of that sentence, and you can then link to that anchor in the same way as you would link to any other anchor.

However, just as with section names, duplicate anchor names only link to the first one. Since anchors aren't displayed, you have a much greater freedom in picking unique anchors, such as by appending the current date and time to the anchor name (for example, by naming an anchor for section "ThisSection" like so: ).

Anchors can be placed anywhere, including at the start of a clause, and inside notes and citations, though it is advisable to test first in your sandbox before trying some exotic new kind of location for the first time. Also the anchor has to be placed after any indicators that are only recognized at the start of a line (such as == for new section, * for new bullet point, : for indentation), as the anchor should still work, but the start-of-line indicator usually no longer will (and you may not always notice this, perhaps especially if you are in a hurry).

There are a small number of special anchor names. See .

Table row linking

To create an anchor for a row of a table, see . However, and are reserved names that link to the top of a page and the table of contents, respectively.

A piped link is an internal link or interwiki link where the link target and link label are both specified. This is needed in the case that they are not equal, while also the link label is not equal to the link target with the last word extended:

  • (label = target, no pipe needed)

    1. produces cheese, linked to the article Cheese.

    (label = target + extension ["s"], no pipe needed)

    1. produces cheeses, linked to the article Cheese.

    (label = part of target, pipe required)

    1. produces cheese, linked to the article Blue cheese.

    (label = target + additional text ["blue"], pipe required)

    1. produces blue cheese, linked to the article Cheese.

    (label is completely different from target, pipe required)

    1. produces that stuff, linked to the article Cheese.

This allows linking a word or phrase within the text of a page rather than using "see also", even if the wording does not exactly correspond with the name of the target page. With a suitable browser and depending on the preferences set, one can still see the link target: when you point at the link, the name shows up in a hover tooltip and is also shown in the status bar.

For instance:

will show: station

This is useful where the word "station" is used in an article on trains; from the context, it would be clear that a train station is meant. The piped link is more convenient to the user than a link to station which might be a disambiguation page.

The word piped refers to the use of the pipe character "|" used to separate the good description from the actual link. This character is named after another use of it; see Pipe (computing).

There are various tricks to get the same result with less typing:

  • Leave the part to the right empty – the "pipe trick"

  • Leave the part to the left empty – the ""

  • ", see MOS:PIPE.

Using a redirect as an alternative

An alternative to a piped link is using a redirect page. For example, it is unnecessary to say . Samuel Clemens is a redirect to Mark Twain, so saying is sufficient. A minor drawback of redirects is that "Related changes" will only display the changes to the redirect page, not the redirect target.

Pipe trick

A wikilink needs a [[fullpagename]], and this is not optional except when it links to or from a subpage. A wikilink to its parent page is ../, and, although no page name is given, the fullpagename is rendered. On the parent a wikilink to a subpage can use [[/subpagename]] to render a subpagename instead.

Although subpages are created in the article space, subpage linking does not fully function there.

Subpage linking works as expected to link to any pages under a root parent page:

The difference between them is that linksto reports a count of links to a page name, while WhatLinksHere reports a map of links to the page as content.

To a section

The navigable links to a section of a page are wikilinks, redirects, and URL-styled wikilinks. The difference between a redirect and a wikilink is most pronounced where a redirect targets a section, when you cannot add your own #section to it even though it appears as [[page name]]. A wikilink that links to a section and that appears as [[page name#section name]] can link to that section through the canonical page name (the title on the page with the actual content) or through the page name of any redirect to it, in which case the page name is the name of a redirect page.

To find wikilinks to a section requires two or more reports.

  1. Show redirects only, an external tool available from the Whatlinkshere page, reports redirects to the content of a section. (No matter which page name you give it, you get all the redirect page names.) Look past any "No anchor or section" group of redirects, and any "invalid" sections, to see if your particular section name is explicitly listed, because then the redirect pages under it can have incoming links that will then go to that section. ("What Links Here" also has a "show redirects" report, but it doesn't specify if the redirect goes to any particular section.)

  2. Use "What Links Here" on any redirect pages found in the previous step.

The more redirects there are, the more reports there are to run. If there are no redirects involved, one report from "Links to" is enough.

From a page

To report links from a page, you simply list all the wikilinks on that page.

  • can count wikilinks from a copy of the wikitext on your local machine.

  • Some text editors support the counting and highlighting of the [[...]] pattern occurrences.

  • The Wikipedia web API accepts queries by URL.

One way to send a query to the API is by creating an external link (). For example, using an external link very much like a search link, you can send the API a request to list the link properties of "wp:example". It should interpret it correctly as "Wikipedia:Example", pageid 25263910.

  1. What you type

  2. [//en.wikipedia.org/w/api.php?action=query&prop=links&pllimit=500&titles=fullpagename your label]

  3. What you get when fullpagename is wp:example

  4. The report is in JSON format, as is usual for RESTful APIs.

  5. The pageid is available from Page information on every page.

  6. The titles parameter is plural. (It is designed to take multiple full page names or pageid, delimited by the | pipe character.)

  7. The number of links returned by this query is limited to 500, per the URL you created. See mw:API:Query for how to safely get more. For example, Operating system has 510 wikilinks.

To make a page register as a link to a page, but without actually showing the link, link to it, but label it with a space character using the pipe trick: [[pagename|]].

Additional link-related functions

For the effect that links have on date formatting, see Help:Date formatting and linking.

Another link-dependent feature is related changes, which makes it possible to view recent changes to all pages that are linked from the current page (or which are members of the category, if it is a category page).

For information on how to link to pages from an image, see mw:Extension:ImageMap.

Several templates have been created to make linking easier (although they are not usually used in article space). These include and for linking to templates, and and for linking to categories. More can be found in :Category:Internal link templates.

Conversion to canonical form

As described previously, if a link target begins with a lower-case letter, it will be interpreted as if it began with the equivalent capital letter. If the target contains a namespace prefix, then the whole prefix and the first character after the colon are case-insensitive (so uSeR:jimbo Wales links to User:Jimbo Wales).

In link targets, spaces and underscores (which are effectively equivalent) are ignored if they come at the start, at the end, or immediately before or after the colon following a namespace prefix. Consecutive spaces/underscores are treated as a single space. Hence _User_: Jimbo_ __ Wales__ links to User:Jimbo Wales.

HTML character references and percent-encoded characters are replaced with their raw character. For example, produces département, and produces %40. Links which resolve to invalid page titles are displayed as unmarked-up wikitext.

Titles indicated by wikilinks are displayed in canonical form (with correction of capitalization and excess spaces/underscores removed, as described previously) in the following places:

  • In transclusion tags for non-existent pages: gives Template:Qwsazx.

  • In tooltips and in the status bar (if applicable for the browser) when the mouse cursor is moved over the link.

  • On redirect pages.

  • In the category box.

The prefixes in interwiki links are treated similarly to namespace prefixes: they are insensitive to case and to spaces before and after the colon. However the first character after the colon is not automatically capitalized (whether it is interpreted as a capital depends on the configuration of the target wiki).

See also

Notes