Help:Link: Difference between revisions

From Absit Omen Lexicon
(Created page with "There are five types of links in MediaWiki: # '''Internal links''' to other pages in the wiki # '''External links''' to other websites...")
 
mNo edit summary
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:
# '''[[#External links to internal pages|External links to internal pages]]''' in the wiki
# '''[[#External links to internal pages|External links to internal pages]]''' in the wiki
# '''[[#Interwiki links|Interwiki links]]''' to other websites registered to the wiki in advance
# '''[[#Interwiki links|Interwiki links]]''' to other websites registered to the wiki in advance
# '''[[#Interlanguage links|Interlanguage links]]''' to other websites registered as other language versions of the wiki


== Internal links ==
== Internal links ==
Line 24: Line 23:
|Piped link  
|Piped link  
|<pre>[[Main Page|different text]]</pre>
|<pre>[[Main Page|different text]]</pre>
See also {{mediawikiwiki|Meta:Help:Piped link}}
|[[Main Page|different text]]
|[[Main Page|different text]]
|-
|-
Line 58: Line 56:
</pre>
</pre>
|
|
[[Help]]<nowiki />ful advice
[[Help:Contents|Help]]<nowiki />ful advice


[[wikipedia:GNU General Public License|GPL]]<nowiki />v3
[[wikipedia:GNU General Public License|GPL]]<nowiki />v3
Line 89: Line 87:
See also [[Help:Magic_words#Page_names]]
See also [[Help:Magic_words#Page_names]]
|[[{{TALKPAGENAME}}|Discussion]]
|[[{{TALKPAGENAME}}|Discussion]]
|-
|Internal link to a subpage
|<pre>[[/example]]</pre>
Shortcut for <nowiki>[[Help:Links/example]]</nowiki>. See also [[Help:Subpages]].
|[[/example]]
|-
|Internal link to a subpage without the leading slash
|<pre>[[/example/]]</pre>
Shortcut for <nowiki>[[Help:Links/example|example]]</nowiki>.
|[[/example/]]
|-
|-
|Internal link to a category page
|Internal link to a category page
Line 234: Line 222:


More details are at [[mediawikiwiki:Manual:Interwiki|Interwiki]].
More details are at [[mediawikiwiki:Manual:Interwiki|Interwiki]].
== Piped link ==
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. 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:
<code><nowiki>[[Ministry of Magic Headquarters|M.o.M. Headquarters]]</nowiki></code> <br />
will show: [[Ministry of Magic Headquarters|M.o.M. Headquarters]]
Another example would be <code><nowiki>[[Potions (class)|Potions]]</nowiki></code> rendering as [[Potions (class)|Potions]]. This is useful where (class) is unnecessary due to context making it obvious the link is referring to the Potions class rather than Potions. 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.
=== Automatic conversion of wikitext with the pipe trick ===
{{See also|Wikipedia:Help:Pipe trick}}
If in a piped link the part after the "|" is left empty, it is converted to an abbreviated form of the linked page, as follows:
# Any word before the first colon (:), as well as the colon itself, is removed. This word may or may not be a namespace prefix (such as "Help:") or an interwiki prefix (such as "commons:"). If the page name is preceded by a colon, "first" refers to "first after this".
# If there is text in parentheses at the end it will be removed.
# If there are no parentheses but there is a comma, the comma and everything after it are removed.
# The link will be in whatever case is used.
In a preview, the result already shows up in the preview itself, but the conversion in the edit box is not yet shown. Press "Show changes" to see the change in the wikitext.
;Category tag
:The sort key syntax of the category being like a piped link, the pipe trick also works for category tags, even though it is not useful there.
;Examples using colons
: <code><nowiki>[[Help:Template|]]</nowiki></code> is converted to <nowiki>[[Help:Template|Template]]</nowiki>, which is rendered as [[Help:Template|Template]].
: <code><nowiki>[[Music: My life|]]</nowiki></code> is converted to <nowiki>[[Music: My life| My life]]</nowiki>, which is rendered as [[Music: My life| My life]] — although "Music:" is not a namespace (therefore the space after the colon is not automatically removed), the shortcut works anyway.
: <code><nowiki>[[w:en:Pipe (computing)|]]</nowiki></code> is converted to <nowiki>[[w:en:Pipe (computing)|en:Pipe]]</nowiki>, which is rendered as [[w:en:Pipe (computing)|en:Pipe]].
;Case examples
: <code><nowiki>[[w:pipe (computing)|]]</nowiki></code> is converted to <nowiki>[[w:pipe (computing)|pipe]]</nowiki> which is rendered as [[w:pipe (computing)|pipe]].
: <code><nowiki>[[w:Pipe (computing)|]]</nowiki></code> is converted to <nowiki>[[w:Pipe (computing)|Pipe]]</nowiki> which is rendered as [[w:Pipe (computing)|Pipe]].
;Comma example
: <code><nowiki>[[commons:Boston, Massachusetts|]]</nowiki></code> is converted to <nowiki>[[commons:Boston, Massachusetts|Boston]]</nowiki>, which is rendered as [[commons:Boston, Massachusetts|Boston]].
;Other examples
:[[Help:Templates#Parameters|Parameters]] and [[Help:magic words#Variables|variables]]:
:<code><nowiki>[[w:{{{1}}}|]]</nowiki></code> does ''not'' give <nowiki>[[w:{{{1}}}|{{{1}}}]]</nowiki>.
: Calling the template with a value of parameter 1 gives a working link in the case of substitution only.
:<code><nowiki>[[w:en:{{FULLPAGENAME}}|]]</nowiki></code> does ''not'' give <nowiki>[[w:en:{{FULLPAGENAME}}|en:{{FULLPAGENAME}}]]</nowiki>.
: <code><nowiki>[[m:{{FULLPAGENAME}}|]]</nowiki></code> does ''not'' give <nowiki>[[m:{{FULLPAGENAME}}|{{FULLPAGENAME}}]]</nowiki>
== Subpage links ==
*A wikilink needs a <kbd>[<nowiki/>[''fullpagename'']]</kbd>, and this is not optional ''except'' when it links to or from a [[Help:subpage|subpage]].
*A wikilink to its parent page is <kbd>[[../]]</kbd>, and, although no page name is given, the fullpagename is rendered.
*A wikilink to a subpage can use the <kbd>[<nowiki />[/''subpagename'']]</kbd> construct, and it will render the subpagename instead of the fullpagename.




Subpage linking works as expected to link to any pages under a root parent page:
* section linking: <kbd>[[../#''section'']]</kbd>
* child-to-child subpage linking: <kbd>[<nowiki />[../''subpagename'']]</kbd>
* parent's parent <kbd>[[../../]]</kbd>
* including the <kbd>[[../|''pipe trick'']]</kbd>


{{Help}}
{{Help}}


[[Category:Help|Links]]
[[Category:Help|Links]]

Latest revision as of 06:55, 6 December 2015

There are five types of links in MediaWiki:

  1. Internal links to other pages in the wiki
  2. External links to other websites
  3. External links to internal pages in the wiki
  4. Interwiki links to other websites registered to the wiki in advance

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 [[#top|current page]] 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).

Description You type You get
Internal link
[[Main Page]]
Main Page
Piped link
[[Main Page|different text]]
different text
Hide namespace shortcut
[[Help:Contents|]]

Short for [[Help:Contents|Contents]]

Contents
Word-ending links
[[Help:Contents|Content]]s

[[Help:Contents|Content]]ing

[[Help:Contents|Content]]ers

[[Help:Contents|Content]]anylettersyoulikehere

Contents

Contenting

Contenters

Contentanylettersyoulikehere

Avoiding word-ending links
[[Help:Contents|Help]]<nowiki />ful advice

[[wikipedia:GNU General Public License|GPL]]<nowiki />v3

Helpful advice

GPLv3

Redirect
#REDIRECT [[Main Page]]

See also Help:Redirects

Main Page
Internal link to an anchor
[[#See also]]

Section headings and the top of the page are automatically anchored.

#See also
Internal link to an anchor from different text
[[#See also|different text]]
different text
Setting an internal link anchor
<div id="NameOfAnchorHere">optional text</div>

Omit the "optional text" for invisible anchor.

optional text
Internal link to an anchor at another page
[[Help:Images#See also]]
Help:Images#See also
Internal link to the current page's talk page
[[{{TALKPAGENAME}}|Discussion]]

See also Help:Magic_words#Page_names

Discussion
Internal link to a category page
[[:Category:Help]]

See also Help:Categories

Category:Help
Internal link to an image or a file of other types
[[media:example.jpg]]

See also Help:Images

media:Bulbgraph.png
Internal link to the user's user page
[[Special:MyPage]]
Special:MyPage

External links

To add an external link, enclose 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.

Description You type You get
External link http://mediawiki.org http://mediawiki.org
External link with different label [http://mediawiki.org MediaWiki] MediaWiki
Numbered external link [http://mediawiki.org] [1]
External links with file icons [http://en.wikipedia.org/wiki/.avi video] [http://en.wikipedia.org/wiki/.ogg sound] [http://en.wikipedia.org/wiki/.pdf document]

See #External link icons for currently supported icons and extensions.

video
sound
document

External link to the same host http://{{SERVERNAME}}/pagename http://absitomen.com/pagename
External link to other host passing the pagename http://google.com/search?q={{PAGENAMEE}}

See also: URL encoded page names

http://google.com/search?q=Link
Mailto link [mailto:info@example.org email me] email me
Mailto named with subject line and body [mailto:info@example.org?Subject=URL%20Encoded%20Subject&body=Body%20Text info] info

External links to internal pages

To add a link to a page on the same wiki using URL query parameters, you may need to use external link syntax.

Description You type You get
External link to the current page's edit page
[http://www.mediawiki.org/w/index.php?title=Help:Links&action=edit Edit]
Edit
External link to the current page's edit page using the fullurl parser function
[{{fullurl:{{PAGENAME}}|action=edit}} Edit]

See also Help:Magic_words#URL_data and #External links

Edit
External link to the current page's edit page, and styled to look like an internal link
<span class="plainlinks">[http://www.mediawiki.org/w/index.php?title=Help:Links&action=edit Edit]</span>

The plainlinks class can be used in cases where you want an external link to look like an internal one, by suppressing the icon that normally appears after it.

Edit

External link icons

Test link Icon Trigger
[2] external-link-ltr-icon.png .external, http://, gopher://
[3] lock-icon.png https://
[4] mail-icon.png mailto:
[5] news-icon.png news://
[6] file-icon.png ftp://
[7] talk-icon.png irc://
[8] audio-icon.png .ogg, .mid, .midi, .mp3, .wav, .wma
[9] video-icon.png .ogm, .avi, .mpeg, .mpg
[10] document-icon.png .pdf, .pdf#, .pdf?

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 <nowiki> tags, like this:

<nowiki>http://mediawiki.org</nowiki>

To get this:

http://mediawiki.org

Interwiki links

Interwiki links are links with the internal link markup to a website registered in advance. For example, you can link to the Hogwarts article on http://en.wikipedia.org by typing [[wikipedia:Hogwarts]], which will result in a link wikipedia:Hogwarts. This is because http://en.wikipedia.org/wiki/ is registered to your wiki by default with the prefix of wikipedia. This link may not work properly, if the admin of your wiki has changed the setting. Unlike internal links, interwiki links do not use page existence detection, so an interwiki link will appear blue even if the page does not exist on the remote wiki.

Similar to internal page links, you can create piped links, with alternate link label, e.g. [[wikipedia:Hogwarts|school]], this is the link school.

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 big yellow flower], 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.

More details are at Interwiki.

Piped link

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

[[Ministry of Magic Headquarters|M.o.M. Headquarters]]
will show: M.o.M. Headquarters

Another example would be [[Potions (class)|Potions]] rendering as Potions. This is useful where (class) is unnecessary due to context making it obvious the link is referring to the Potions class rather than Potions. 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.

Automatic conversion of wikitext with the pipe trick

If in a piped link the part after the "|" is left empty, it is converted to an abbreviated form of the linked page, as follows:

  1. Any word before the first colon (:), as well as the colon itself, is removed. This word may or may not be a namespace prefix (such as "Help:") or an interwiki prefix (such as "commons:"). If the page name is preceded by a colon, "first" refers to "first after this".
  2. If there is text in parentheses at the end it will be removed.
  3. If there are no parentheses but there is a comma, the comma and everything after it are removed.
  4. The link will be in whatever case is used.

In a preview, the result already shows up in the preview itself, but the conversion in the edit box is not yet shown. Press "Show changes" to see the change in the wikitext.

Category tag
The sort key syntax of the category being like a piped link, the pipe trick also works for category tags, even though it is not useful there.
Examples using colons
[[Help:Template|]] is converted to [[Help:Template|Template]], which is rendered as Template.
[[Music: My life|]] is converted to [[Music: My life| My life]], which is rendered as My life — although "Music:" is not a namespace (therefore the space after the colon is not automatically removed), the shortcut works anyway.
[[w:en:Pipe (computing)|]] is converted to [[w:en:Pipe (computing)|en:Pipe]], which is rendered as en:Pipe.
Case examples
[[w:pipe (computing)|]] is converted to [[w:pipe (computing)|pipe]] which is rendered as pipe.
[[w:Pipe (computing)|]] is converted to [[w:Pipe (computing)|Pipe]] which is rendered as Pipe.
Comma example
[[commons:Boston, Massachusetts|]] is converted to [[commons:Boston, Massachusetts|Boston]], which is rendered as Boston.
Other examples
Parameters and variables:
[[w:{{{1}}}|]] does not give [[w:{{{1}}}|{{{1}}}]].
Calling the template with a value of parameter 1 gives a working link in the case of substitution only.
[[w:en:{{FULLPAGENAME}}|]] does not give [[w:en:{{FULLPAGENAME}}|en:{{FULLPAGENAME}}]].
[[m:{{FULLPAGENAME}}|]] does not give [[m:{{FULLPAGENAME}}|{{FULLPAGENAME}}]]


Subpage links

  • 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.
  • A wikilink to a subpage can use the [[/subpagename]] construct, and it will render the subpagename instead of the fullpagename.


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

  • section linking: [[../#section]]
  • child-to-child subpage linking: [[../subpagename]]
  • parent's parent [[../../]]
  • including the [[../|pipe trick]]