Help:Links
There are four sorts of links in MediaWiki:
- internal links to other pages in the wiki
- external links to websites
- interwiki links (links to other wikis)
- inter-language links to other language versions of the same wiki
To add an internal link, enclose the name of the page you want to link to in double square brackets. When you save the page, you'll see the new link pointing to your page. If the page exists already, it is displayed in blue, empty pages are displayed in red. Selflinks to the current page are not transformed in URLs but displayed in bold.
The first letter of the target page is automatically capitalized and spaces are represented as underscores (typing an underscore in the link will have a similar effect as typing a space, but is not recommended, since the underscore will also be shown in the text).
How to link
Description | You type | You get |
Internal link | [[Main Page]] | Main Page |
Piped link | [[Main Page|different text]] | different text |
External link | http://mediawiki.org | http://mediawiki.org |
External link, different title |
[http://mediawiki.org MediaWiki] | MediaWiki |
External link, numbered |
[http://mediawiki.org] | [1] |
Anchor link | [[#See also]] | #See also |
Anchor link at another page | [[Help:Images#See also]] | Help:Images#See also |
Category link | [[:Category:Help]] | Category:Help |
Internal link to image file | [[media:example.jpg]] | media:example.jpg |
Interwiki link | [[Wikipedia:MediaWiki]] | Wikipedia:MediaWiki |
mailto link | [mailto:info@example.org email me] | email me |
redirect | #REDIRECT [[Main Page]] | → Main Page |
More advanced
Description | You type | You get |
Piped link, different title |
[[Main Page|<span title="different title">different text</span>]] | different text |
External link, same host unnamed |
[http://{{SERVERNAME}}/pagename] | [2] |
mailto named with subject line and body | [mailto:info@example.org?Subject=URL%20Encoded%20Subject&body=Body%20Text info] | info |
Setting anchors
- headers automatically become html anchors, which can be linked to.
- The <a> tag is not allowed in MediaWiki, so we can't do the <a name="link here">, but we can do the "id" html attribute to almost any existing tag. For example, <div id="what_to_link_to">text</div> or <div id="what_to_link_to"/>text.
File:Tools.svg | Tip for wiki admins: Which protocols (like http:) are allowed for links is controlled by the $wgUrlProtocols setting. |
File:Tools.svg | Tip for wiki admins: To remove the 'external link image' from next to each of the external links, add the following to the page located at MediaWiki:Monobook.css on your wiki.
#bodyContent a.external, #bodyContent a[href ^="gopher://"] { background: none; padding-right: 0; } |
How to avoid auto-links
By default, when you write a URL as is, it will be transformed in an external link.
To avoid that effect, put the URL between <nowiki> start & end tags as in:
<nowiki>http://mediawiki.org</nowiki>
Interwiki links
Interwiki links are links from the local wiki to another wiki. For example you can link to the Sunflower article on wikipedia.org by typing [[wikipedia:Sunflower]]. This results in a link like this: wikipedia:Sunflower
Similar to internal page links, you can create piped links, with alternate link text. e.g. [[wikipedia:Sunflower|big yellow flower]]
Basically this is an abbreviation for longer URLs. A very similar link could be created as a normal external link by typing [http://en.wikipedia.org/wiki/Sunflower Sunflower], but interwiki links allow you to type out an easy and compact link, almost as if you are linking to a page on your own wiki.
Some interesting things to note:
- Interwiki links are displayed slightly differently to external links, without the little external link icon.
- Complex page names with spaces and other characters, are handled elegantly, just as they would be for an internal page link, making this more tidy than creating an external link to a full URL. For example [[wikipedia:Sunflower County, Mississippi]] is in some ways tidier and more elegant than the full URL : http://en.wikipedia.org/wiki/Sunflower_County%2C_Mississippi