MediaWiki使用手冊: 目錄 · 讀者手冊 · 編輯手冊 · 仲裁員手冊 · 系統管理員手冊 +/-


Hyperlinks allow users to move between pages. For some basic information about using hyperlinks, see Help:Editing#Links. There are three general types of hyperlinks recognized by MediaWiki, each with associated CSS formatting to distinguish them.


維基連結是一種內部連結, 連接到維基內部的頁面. 雖然可以使用某些[w:HTML|HTML]語法來 code 這些連結, 但是維基提供使用者獨特的標記語言, 方便使用者簡單又快速地建立維基連結. 这种语言被称为wikitext语言wiki标记. Meta wikitext语言语法以及其它的Wikimedia项目都是由软件MediaWiki定义的.


MediaWiki 對維基連結的定義為一對面向內側的中括弧, 如同以下的標點符號所示:'[[ ]]'. 其链接目标是紧跟在一对中括弧'[['后的字符序列,直至遇到空格、管道'|'或另一对中括弧']]'(从左向右读取).

輸入  輸出    目標      敘述   
[[a]]  a    a     最簡單的內部連結  
[[a|b]]  b    a     連到'a'目標,但顯示為'b' *  
[[a]]b  ab    a     'b' 是維基連結 'a' 的結尾字  
<nowiki>[[a]]</nowiki>  [[a]]    Ø     直接輸出 <nowiki></nowiki>內的文字, 而且不具連結功能  
[[w:Image:Bobdobbs.jpg|]]  Image:Bobdobbs.jpg    w:Image:Bobdobbs.jpg     A pipe '|' immediately before the closing bracket pair ']]' hides the first prefix of the link when it is displayed *  
[[a|b|c]]  b|c    a     維基標記視第二個 | 為純文字*  
[[a|b]]c  bc    a     'c'成為維基連結的結尾字*  
a[[b]]  ab    b     'a' immediately precedes the link text but is not included  
[[a]]<nowiki>b</nowiki>  a   a     'b' immediately follows the link text but is not included  
[[a]]''b''  ab    a     Using double apostrophes '' around 'b' to make it italicized excludes it from the link text  
''[[a]]''b  a   a     Using triple apostrophes ''' around 'b' to make it italicized excludes it from the link text  
[[a|b]]c<nowiki>d</nowiki>  bc   a     Translates like [[a|bc]]<nowiki>d</nowiki> *  
[[a]][[b]]  ab    a , b     兩個緊靠在一起的維基連結. 除非將游標移至其上,否則看起來像是ab  

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

MediaWiki automatically checks if the target of a wikilink exists ("existence detection"). If the page doesn't exist, the link leads 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 a future page, facilitates and incites page creation.

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, [[:Category:Help]], [[:fr:Help:Link]], and [[:Image:Mediawiki.png]].

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

Stub featureEdit

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. 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.

Interwiki linksEdit

An interwiki link links a page to a page on another website. Unlike the name suggests, the target site need not be a wiki, but it has to be on the interwiki map specified for the source wiki. These links have the associated CSS class "extiw". These are in the same form as wikilinks above, but take a prefix which specifies the target site. For example, on Wikimedia projects and many other wikis [[wikipedia:Main Page]] links to Wikipedia's main page. The prefix can be hidden using the same piped syntax as wikilinks.

Interwiki links to the same projectEdit

Although interwiki links can be used to point to a wiki from itself, this is not generally recommended. MediaWiki does not detect whether or not the target page of an interwiki list exists, so there is no special formatting and the link is always to the view page. Further, MediaWiki does not check if the page is linking to itself. A self wikilink is bolded (like Help:Link/zh), whereas a self interwiki link is normal (m:Help:Link/zh).


  • A copy of the wikitext on a sister project may still point to the same page. Sometimes two prefixes are needed for that purpose, e.g. w:de:a.

External linksEdit

External links use absolute URLs to link directly to any webpage. These links have the associated CSS class "external". External links are in the form [ link name] (resulting in link name), with the link name separated from the URL by a space. Links without link names will be numbered: [] becomes [1]. Links with no square brackets will be displayed in their entirety: .

Unlike in the case of internal links, [ a]s gives as.

See URLs in external links for more detailed information.

Special:Linksearch finds all pages linking to a given site.

External links to the same projectEdit

External links are often used to use special URL parameters in links. This allows links directly to the edit history of a page, to a page in edit view, a diff of two versions, et cetera. They can also be used to create a navigational image.

However, the use of external links to link to a normal page on the same project is not recommended. These links benefit from none of the features of a wikilink, and may break the web of links when the content is exported to another domain.


Monobook skin 在每個外部連結之後產生一張箭頭圖示. 如果想要停止顯示該圖示, 請使用 class="plainlinks":

  • <span class="plainlinks">http://a</span> 的輸出為 http://a
  • http://a 的輸出為 http://a

Section linking (anchors)Edit

Links in the form [[#anchor_name]] will link to any anchor named "anchor_name" on the page. This may be either a heading named "anchor_name", or an arbitrary position. [[#top]] is a reserved name that links to the top of a page. It is possible to create an arbitrary anchor name using the HTML code <span id="anchor_name"></span>.

Anchor links can also be appended to any type of link; for more information, see Help:Section#Section_linking.

Problems with page name conversionEdit

Note that if the page name is automatically converted (for example, from "/wiki/main Page" to "/wiki/Main Page"), the section link will still work but will disappear from the address bar. As a consequence, this will make it more difficult to bookmark the section itself. This is not applicable for wikilinks, because the conversions have already taken place on Preview or Save of the referring page.

For example, consider In this case, the anchor part of the address will disappear because the "how" will be converted to "How".

Redirects with section linksEdit

A redirect to a page section does not go to the section. However, one can add the section anyway as a clarification, and it will work if the redirect is manually clicked from the redirect page. However, links with a section to a redirect will lead to the section on the redirect's page.

Subpage featureEdit

MediaWiki has a subpage feature, although activation depends on project and namespace. If activated, the following applies (if not, "A/b" is just a page with that name).

A tree structure of pages is established by using forward slashes in pagenames: A/b is a child of A, hence A is a parent of A/b; also A/b/c is a child of A/b; A/a, A/b, and A/c are siblings.

At the top of the subpage body links to all ancestor pages are shown automatically, without any corresponding wikitext. The links show up even if the parent page does not exist, but the sequence of ancestors stops before any non-existing ancestor page (e.g., if the grandparent page does not exist, the parent page is not shown either). Like most letters of a page name, the first letter after the slash is case-sensitive; "/subpage" and "/Subpage" are different pages.

What links here and Related changes ignore these automatic links.

Relative linksEdit

Relative links still work if all pages of a tree are renamed according a name change of the root, including making it a child of a new root.

Inside a subpage hierarchy the following relative links can be used:

  • [[../]] links to the parent of the current subpage, e.g., on A/b it links to A, on A/b/c it links to A/b.
  • [[../s]] links to a sibling of the current subpage, e.g., on A/b, it links to A/s.
  • [[/s]] links to a subpage, e.g. on A it is the same as [[A/s]].

See also w:Wikipedia:Subpages, and the example pages m:Link/a/b and m:Help:Link/a/b. For the latter the subpage feature does not work because of the namespace.

User spaceEdit

Subpages of a user page ([[User:Username/Subpage]]) are considered to be in that user's "user space". Rules are often relaxed in a user's own subpages, whereas they are typically tightened for a user editing another user's subpages.

Unintended subpage structureEdit

Any slash in a pagename causes a subpage structure, e.g. Subpage demo Season 2006/2007 is a subpage of "Subpage demo Season 2006". As long as the latter does not exist, this has no effect on the former. However, a page with a slash in its name cannot be the root page of a subpage structure. For example, Subpage demo Season 2006/2007 /soccer does not show its parent, because its unintended grandparent does not exist. A dummy grandparent page can fix this.

Subpage activationEdit

Wikipedia has this feature activated in all talk namespaces and the user and project namespace. The Meta-Wiki also has it in the main namespace. The default is set in DefaultSettings.php[2]. As of revision 1.21, the following namespaces have it activated by default: Special, Main talk, User and User_talk, Meta_talk, and Image_talk. Settings per project are changed in LocalSettings.php[3].


Linking to a page with imagesEdit

It is possible to use images as links to other pages. For more information, see use an image as a link to a page.

"Hover box" on linksEdit

On some browsers, holding the cursor over link will show a hover box containing the text of the link's HTML title attribute. MediaWiki sets this to the target page name (without the possible section indication) if it's a wikilink, the page name with prefix if it's an interwiki link, and the URL if it's an external link.

This can be switched off in the user preferences. The browser may also show similar info, but with the possible section indication, in the address bar.

For these effects a piped link is useful even if it not followed; for example, for displaying the meaning of an acronym (e.g. NPOV) or any other remark. It is possible to produce a hover box without a link, see Template:H:title.

Disallowed charactersEdit

In internal and interwiki link style, a plus sign in a page name is not allowed, the HTML and hence the rendered page just shows the wikitext, e.g. a+b. In external link style a plus sign in the URL is retained. It is often equivalent with a space. See also below.

In accordance with the rules explained in Help:Page name, conversions are automatically made to non-literal characters in wiki and interwiki links. For example, "[[Help:Page%20name]]" becomes "Help:Page name". However, the opposite is true for external links; literal characters are converted into non-literal characters. For example, most browsers will convert ".../wiki/!" to ".../wiki/%21".

A code like %70 in a redirect disables it, although the link works from the redirect page. For a redirect that works, the redirect page shows the canonical form of the target, unlike its preview page, which renders the link in the usual way.

Special pipe syntaxEdit

Using an empty pipe syntax on wiki and interwiki links will hide interwiki prefixes and parentheses. For example, [[w:Mercury (planet)|]] becomes Mercury. This pipe syntax should only be used where the unqualified reference is not ambiguous, such as in an article about the solar system. See Help:Piped link.

Additional effects of linksEdit

  • Related changes
  • Backlinks
  • Date format
  • Using a space after the pipe syntax ([[main Page| ]]) produces (perhaps depending on the browser) a space only, not a link (" "), but it is treated as a link for the "what links here" feature.

Links from a pageEdit

With query the links from page pagename, sorted by namespace, and for each namespace alphabetically, are given by {{SERVER}}{{SCRIPTPATH}}/query.php?what=links&titles=pagename , e.g. // .






Links to other help pages

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · Wikidata · MediaWiki · Wikibooks · Wikisource · MediaWiki: Manual · Google
Versions of this help page (for other languages see further)
What links here on Meta or from Meta · Wikipedia · MediaWiki
Go · Search · Stop words · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences · User style
Starting a new page · Advanced editing · Editing FAQ · Edit toolbar · Export · Import · Shortcuts · Edit conflict · Page size
Links · URL · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · List · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Testing · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Variable · System message · Substitution · Array · Calculation · Transclusion
Special characters · Renaming (moving) a page · Preparing a page for translation · Talk page · Signatures · Sandbox · Legal issues for editors