5,462 bytes added
, 14:52, 15 April 2013
Links in MediaWiki:
# '''[[#Internal links|Internal links]]''' to other pages in the wiki
# '''[[#External links|External links]]''' to other websites
== Internal links ==
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, if it does not, in red.
Selflinks to the current page are not transformed in URLs but displayed in bold.
(If you really want to link to the current page, use an anchor (see below), or <nowiki>[[#top|current page]]</nowiki> which always links to the top.)
The first letter of the target page is automatically capitalized, unless otherwise set by the admins, 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).
{| border="1" class="wikitable"
!Description
!You type
|-
|Internal link
|<pre>[[Main Page]]</pre>
|-
|Piped link
|<pre>[[Main Page|different text]]</pre>
|-
|[[w:Help:Pipe_trick|Pipe trick]]
|<pre>
[[Help:Contents|]]
[[User:John Doe|]]
[[Extension:DynamicPageList (Wikimedia)|]]
[[Extension:DynamicPageList (third-party)|]]
</pre>
The pipe trick quickly makes shorter link text, but could be confusing in circumstances like the DynamicPageList link examples.
|-
|<span id="linktrail"></span>Word-ending links, following so called "linktrail rules" [[Localisation|localised]] per [[MessagesXx.php|each language]]
|<pre>
[[Help]]s
[[Help]]ing
[[Help]]ers
[[Help]]almostanylettersyoulikehere
</pre>
|-
|Avoiding word-ending links
|<pre>
[[Help]]<nowiki />ful advice
[[wikipedia:GNU General Public License|GPL]]<nowiki />v3
</pre>
|-
|Redirect
|<pre>#REDIRECT [[Main Page]]</pre>
See also [[Help:Redirects]]
|-
|Internal link to an anchor
|<pre>[[#See also]]</pre>
[[Help:Formatting|Section headings]] and the [[#top|top]] of the page are automatically anchored.
|-
|Internal link to an anchor from different text
|<pre>[[#See also|different text]]</pre>
|-
|Setting an internal link anchor
|<pre><div id="NameOfAnchorHere">optional text</div></pre>
Omit the "optional text" for invisible anchor.
|-
|Internal link to an anchor at another page
|<pre>[[Help:Images#Supported media types for images]]</pre>
|-
|Internal link to an image or a file of other types
|<pre>[[media:example.jpg]]
[[media:example.pdf]]</pre>
See also [[Help:Images]]
|}
== External links ==
To add an external link, enclose the URL followed by space and the name of the page you want to link to in single square brackets. When you save the page, you'll see the new link pointing to your page, with an arrow icon after it to show that it was coded with single bracket external link syntax, and thus may lead to another site.
{| class="wikitable"
!style="width:15%"|Description
!style="width:45%"|You type
|-
|External link
|<tt><nowiki>http://mediawiki.org</nowiki></tt>
|-
|External link with different label
|<tt><nowiki>[http://mediawiki.org MediaWiki]</nowiki></tt>
|-
|Numbered external link
|<tt><nowiki>[http://mediawiki.org]</nowiki></tt>
|-
|External links with file icons
|<tt><nowiki>
[http://en.wikipedia.org/wiki/.avi video]
[http://en.wikipedia.org/wiki/.ogg sound]
[http://en.wikipedia.org/wiki/.pdf document]
</nowiki></tt>
|-
|Mailto link
|<tt><nowiki>[mailto:info@example.org email me]</nowiki></tt>
|-
|Mailto named with subject line and body
|<tt><nowiki>[mailto:info@example.org?Subject=URL%20Encoded%20Subject&body=Body%20Text info]</nowiki></tt>
|}
=== External link icons ===
{| class="wikitable"
! Test link !! Icon !! Trigger
|-
| [http://.] || [http://bits.wikimedia.org/skins-1.17/vector/images/external-link-ltr-icon.png external-link-ltr-icon.png] || <code>http://</code>, <code>gopher://</code>
|-
| [https://.] || [http://bits.wikimedia.org/skins-1.17/vector/images/lock-icon.png lock-icon.png] || <code>https://</code>
|-
| [mailto:.] || [http://bits.wikimedia.org/skins-1.17/vector/images/mail-icon.png mail-icon.png] || <code>mailto:</code>
|-
| [news://.] || [http://bits.wikimedia.org/skins-1.17/vector/images/news-icon.png news-icon.png] || <code>news<nowiki/>://</code>
|-
| [ftp://.] || [http://bits.wikimedia.org/skins-1.17/vector/images/file-icon.png file-icon.png] || <code>ftp://</code>
|-
| [irc://.] || [http://bits.wikimedia.org/skins-1.17/vector/images/talk-icon.png talk-icon.png] || <code>irc://</code>
|-
| [http://.ogg] || [http://bits.wikimedia.org/skins-1.17/vector/images/audio-icon.png audio-icon.png] || <code>.ogg</code>, <code>.mid</code>, <code>.midi</code>, <code>.mp3</code>, <code>.wav</code>, <code>.wma</code>
|-
| [http://.ogm] || [http://bits.wikimedia.org/skins-1.17/vector/images/video-icon.png video-icon.png] || <code>.ogm</code>, <code>.avi</code>, <code>.mpeg</code>, <code>.mpg</code>
|-
| [http://.pdf] || [http://bits.wikimedia.org/skins-1.17/vector/images/document-icon.png document-icon.png] || <code>.pdf</code>, <code>.pdf#</code>, <code>.pdf?</code>
|}
=== How to avoid auto-links ===
When you put a URL on a wiki page it will be automatically converted into an external link, like this:
http://mediawiki.org
To avoid that effect, put the URL between <tvar|1><code><nowiki></code></> tags, like this:
<pre><nowiki>http://mediawiki.org</nowiki></pre>
To get this:
<nowiki>http://mediawiki.org</nowiki>