Help:Wikilinks

Wikilinks
A wikilink is an internal link to another page or page-section within the same wiki. MediaWiki automatically checks if the target of a wikilink exists ("existence detection"). If the page doesn't exist, the link leads instead to the editing screen, and it is assigned the class "new". Such wikilinks are nicknamed "red links" because they are colored red in the default stylesheet on a default installation of MediaWiki. "Red links" are useful in determining the current status of the page (created or not created), create links to future pages, and facilitate and encourage creation of new pages. Also, through "What links here" applied to the non-existing page they provide indirect links to other pages with the same red link.

A link to a non-existing page in the MediaWiki namespace for an existing system message counts as a link to an existing page.

Syntax
MediaWiki defines a wikilink as a closed set of inward facing square bracket pairs '  '. The link target is the sequence of characters immediately following the first bracket pair until pipe '|' or the opposing bracket pair ']]' is encountered (read from left to right). The link target can be another page on the wiki, a section on the same page as the link, or a section on another page on the wiki.


 * Inter-page links: Links of the form  link to the page that exactly matches that "page_name".


 * Intra-page links: Links of the form  link to the first section on that same page, that has a heading (or anchor -- see below) which exactly matches that "link_name".


 * Inter-page "intra" links: Links of the form  link to the matching section of the matching page, see section linking.

The wikilinks syntax also includes various formatting-options to control how a link and its visible text appear.

* Links with parameters (the link name) are said to be "piped" because of the pipe symbol used.

** Regardless of whether the prefix is an interwiki link prefix, a namespace prefix, or just some text with a colon.

*** Does not work with #-wikilinks (intra-page links): renders any as pure text.

(spaces are preserved, but the link target is the page with the name obtained by removing them)

(a newline is not allowed in the link target or link label)

Note that the image, category, and interlanguage syntax are the same as the wikilink syntax. Attempting to link normally will place the image on the page, add the page to the category and create an interlanguage link at the edge of the page. This can be prevented by prefixing a colon, which escapes the specific syntax. For example,,  , and.

In the case of a link to a local, non-existing, dynamically generated image description page of an image on Commons, this page is counted as existing for links on pages, e.g. File:Cow-on pole, with horns.jpeg, but not for links in edit summaries and logs.

The existence of an internal link from a page to an existing or non-existing page is recorded in the pagelinks table.

The maximum link length (before optional bar character) is 255 bytes, after expansion of  and   and UTF-8 encoding.

Stub feature
A wikilink to an existing page will be in class 'stub' if the page is in the main namespace, it is not a redirect, and the number of bytes of the wikitext is less than the "threshold for stub display" set in the user's preferences.

This allows users to immediately identify links to very short pages that probably need to be expanded, and links to short disambiguation pages. Alternately, a user may set a very high threshold to achieve any of the following:
 * Identify links to very large pages. However, the criterion is the size of the wikitext; possible inclusion of templates and images can make the rendered page large, even if the amount of wikitext is small.
 * Determine at a glance whether a link leads to the main namespace or not. However, this does not take into account redirects to the main namespace (even if the redirect itself is in the main namespace).
 * Identify links to redirects, for clean-up work such as bypassing redirects.

However, section linking to a "stub" does not work. Although this is normally a minor issue, this may cause problems with users who set a very high threshold.