Help:Link
This is a copy of the master help page at m:Help:Link. Do not edit this page. Edits will be lost in the next update from the master page. Either edit the master help page for all projects at Meta, or edit the project-specific text at Template:Ph:Link. You are welcome to copy the exact wikitext from the master page at Meta and paste it into this page at any time.
For some basics, see also Help:Editing#Links, URLs.
Linking from a page
editThe following types of hyperlink can be distinguished:
- internal link in internal link style (no class, class='stub', or class='new', see below), e.g. a, Main page
- interwiki link in internal link style (class='extiw'), e.g. w:en:a
- link in external link style (class='external'), e.g. http://a.org
(the classes can be used for separate colors or fonts per class by means of a specification in a CSS)
If no link label is specified, 1 and 2 are of the form ''target'' (with in case 2 target starting with a prefix) and 3 is of the form target, where target is the URL including "http://" (ftp:// also works, but file:// does not). In case 3 no blank space is allowed in the URL. For MediaWiki pages the blank space can be replaced by an underscore, in general also %20 can be used; see also URLs in external links.
There are two ways of allowing the link label and the (eventual) link target to be chosen independently:
- a label can be specified with in case 1 and 2 label and in case 3 [ target label ], with a blank space in between, see Help:Piped link.
- a page with the name of the link label redirects to the eventual link target.
In the first case the link title is the name of the (eventual) target page, in the second case it is equal to the link label. By using a piped link and a redirect, the label, title, and target can all be chosen independently, see also below.
Correspondingly, there are two ways to use an image as link to a page:
- In the first method, only possible in projects that allow embedding images in external link style, an image plays the role of the label.
- In the second method, the image description page contains a redirect.
In case 3, links like [ target ] are automatically labelled with serial numbers 1, 2, 3, ...
For link type 1 there is an existence detection feature: it will be a link to the viewing page if the page exists at the time of loading or previewing of the referring page (no class or class='stub'), otherwise to the edit page (class='new'; "red link").
For an internal link to an image or category, prefix a colon. A link to a non-existing image gives: Image:Abc
From MediaWiki 1.5 it leads to the upload page. |
Stub feature
editA link in internal link style to an existing internal page will be in class 'stub' iff all the following is true:
- the page is in the main namespace
- the page is not a redirect
- the number of bytes of the wikitext is less than the value of the "threshold for stub display" specified in the preferences
The idea behind this is that such pages are "stubs" which need fixing, or which are less worthwhile to go to. Alternatively, with a higher threshold value, the feature allows indication that a page is large (with a slow connection perhaps a reason not to go to it). However, note that due to the possible inclusion of templates and images, a small wikitext does not necessarily mean a small composite page in terms of amount of information, or amount of bytes to load. On the other hand, a page about a subtopic with a link to the parent page and with the same category tags may exceed a stub threshold without containing any additional info not provided by the parent page.
Also, by specifying a very high value as threshold, this feature allows, instead of the intended use of distinction according to size:
- distinction according to namespace (in the main namespace or not); however, redirects in the main space are marked "as if in another namespace", regardless of the namespace of the target of the redirect
- for links to the main namespace, known from the hoverbox or status bar, an indication of links having a redirect as target; therefore, for clean-up work involving bypassing redirects, temporarily using a very high stub threshold value is convenient.
However, section linking to a "stub" does not work; normally that would not matter, but with these special uses of the stub feature, with higher threshold values, it does. In this regard it is better to use external link style for section linking, that works anyway.
Miscellaneous
editInternal link style vs interwiki link style: pros and cons
editPros:
- 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.
Cons:
- depending on the CSS it may look different
- there is no existence detection:
- the link is always to the view page, not to the edit page
- the link does not look different if the page does not exist
- the self-link feature does not work
Example:
If you are viewing the master copy on Meta of this help page then some of the above is demonstrated here:
- compare Help:Lnik and m:Help:Lnik (for the demo this page should not exist, please do not create it)
- compare Help:Link and m:Help:Link (self link)
Cases where using external link style for an internal or interwiki page can be useful
edit- linking to the edit page of an existing internal page
- linking to an edit page on a sister wiki (including a non-existing page, the link being an invitation or preparation for creating one, just like is common for internal pages)
- linking to a page for which internal link style is not possible, such as an old version of a page, a diff of two versions, Recent Changes or Watchlist with parameters, Backlinks page, etc.
bm,bnm,
Redirects
editA redirect to a section of a page does not go to the section. One can use it anyway as a clarification, and at least it works when clicking on the link from the redirect page.
A link that specifies a section of a redirect page corresponds to a link to that section of the target of the redirect.
"Hover Box" on hyperlinks
editOn some browsers, putting the mouse pointer over a hyperlink will show a hover box with the title attribute in the link anchor in the HTML code. This is the page name (without the possible section indication) in case 1, the page name with prefix in case 2, and the URL in case 3. Oddly, the title is not present at interlanguage links (at the page margin).
This can be switched off in the 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, e.g. for displaying the meaning of an acronym, the municipality to which a town belongs, or any other remark: UN, Voorburg, example. Apart from the last example, the whatsapp business this works best on Wikipedias, where often the explanation corresponds with the pagename. Here the prefixes "w:en:" have been put to make the links work from other projects; these clutter the explanation in the hover box a little.
For just a remark it gives confusion with the usual meaning of a link to a non-existing page: an invitation to create the page. One can also produce a hover box without link.
Plus sign in a link
editIn 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.
Other conversions
editIn accordance with the rules explained in Help:Page name, conversions are made. This is demonstrated in the following examples:
[[__%20_%70RoJecT %20 : a b : c # d___%20]] [[__%20_%70RoJekT %20 : a b : c # d___%20]] [[ w:__%20_%70RoJecT %20 : a b : c # d___%20]]
become links to
http://meta.wikipedia.org/w/wiki.phtml?title=Meta:A_b_:_c_&action=edit http://meta.wikimedia.org/w/wiki.phtml?title=PRoJekT_:_a_b_:_c_&action=edit http://en.wikipedia.org/wiki/pRoJecT_:_a_b_:_c_%23_d
and show up as
__ _pRoJecT : a b : c # d___ __ _pRoJekT : a b : c # d___
w:__ _pRoJecT : a b : c # d___
(see also the hover box and the status bar)
while in
http://en.wikipedia.org/wiki/__%20_%70RoJecT_%20_:__a___b___:__c__#__d___%20
nothing is changed (except that when the browser reports the link target, %70 is converted to p).
Note that a project does not keep a record of namespace prefixes or capitalization settings of sister projects, therefore less conversions can take place in an interwiki link than in an internal link.
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.
Linking to a page, a section, or an arbitrary position in a page
editA plus sign in the page name in the URL is equivalent with a space, e.g. //en.wikiquote.org/wiki/a+b leads to the page A b.
Apart from linking to the top, one can link to a section, see Help:Section#Section_linking. Also one can create an anchor at an arbitrary position and link to that. One can not use a HTML element "a" (see Help:HTML in wikitext), but one can make a span or div tag like <span id=".." /> or add id=".." to the start tag of any existing HTML element.
If, on applying the link, the page name has to be converted, e.g. capitalized, then section linking still works, but the anchor part of the address disappears from the address bar. A consequence is e.g. that one can not conveniently bookmark the URL with anchor, after applying the link.
This is not applicable for internal links, because the conversions have already taken place on Preview or Save of the referring page.
Consider e.g.:
- http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page#See_also
- http://en.wikipedia.org/wiki/wikipedia:How_to_edit_a_page#See_also
- http://en.wikipedia.org/wiki/Wikipedia:how_to_edit_a_page#See_also
The anchor part of the address disappears from the address bar in the 2nd and 3rd case.
Conversions:
http://meta.wikipedia.org/w/wiki.phtml?title=Meta:A_b_:_c_&action=edit
http://en.wikipedia.org/wiki/pRoJecT_:_a_b_:_c_#_d
http://en.wikipedia.org/wiki/__%20_pRoJecT_%20_:__a___b___:__c__#__d
lead to Meta:A b : c and twice to w:Wikipedia:A b : c
Linking within a page
editYou can use [[#Anchors]] to easily anchor to a header on the same page. For example #Anchors and Linking from a page.
Link titles
editAs shown by the examples a#b, w:a#b, http://a.b#c, giving the link titles a, w:a, and http://a.b#c, respectively (also for the piped link versions), the anchor is in the title in the external link style, but not in the internal link style and not in the interwiki link style. However, even if the anchor is not in the title and even if the browser does not show the URL in the hover box, the anchor can still be seen in the status bar.
Since the HTML element "a" is disabled when put directly in the wikitext, one can not choose the link target and link title independently. This would be useful e.g. to link the word "inch" to the article "inch", with link title "2.54 cm", so that one gets informed through the hover box even without following the link. A workaround is to link to a page named "2.54 cm", which redirects to "inch".
Subpage feature
editDepending on the project, for certain namespaces a subpage feature is enabled. On Wikipedia this is in talk namespaces, and the user and project namespace, on Meta also in the main namespace. The default set in DefaultSettings.php [1] was, as of revision 1.21:
# which namespaces should support subpages? See Language.php[2] for a list of namespaces # default: only discussion ("talk") namespaces and user pages # allow subpages # 0=no subpages, 1=subpages $wgNamespacesWithSubpages = array( -1 => 0, 0 => 0, 1 => 1, 2 => 1, 3 => 1, 4 => 0, 5 => 1, 6 => 0, 7 => 1 );
Settings per project are done in LocalSettings.php [3].
A page with a name of the form A/b is considered a so-called "subpage" of the page A.
From the parent page it can be linked to with simply [[/b]] or the corresponding piped link. In namespaces for which the feature is disabled, this gives a link to the page with full page name "/b". On this project in this namespace it gives: /b.
At the top of the subpage body a link to the parent page is shown automatically, without any corresponding wikitext. The link shows up even if the page A/b does not exist, provided that the page A exists.
Like most letters of a page name, the first letter after the slash is case-sensitive, A/B and A/b are different.
Subpages can have subpages themselves. Links to the whole hierarchy line of pages from the top is shown on the page.
What links here and Related changes ignore these automatic links.
Pages with a name of the form User:A/B are considered to be in the set of user pages of user A. Typically, with regard to such pages, more relaxed rules apply for user A, and more strict rules for other users, than with regard to other pages.
Inside a subpage hierarchy the following links can be used:
- [[../]] - links to the parent of the current subpage.
- [[../Sibling]] - links to a sibling of the current subpage, e. g. from [[Parent/Subpage]] [[../Sibling]] links to [[Parent/Sibling]]
[[/Subpage/]] is equivalent to [[/Subpage|Subpage]].
See also w:Wikipedia:Subpages.
Repairing links when disambiguating pages
editWhen repairing a link during disambiguation, for example when renaming the article Mercury to Mercury (planet), you can use empty pipe syntax so that the link does not contain the new parenthesized qualifier. For example, [[Mercury (planet)|]] will render as "Mercury" just like the original. This is easier to edit and maintain than the more wordy [[Mercury (planet)|Mercury]]. This pipe syntax should only be used where the unqualified reference is not ambiguous, such as in a article about the solar system.
Special effects of links
edit- embedding an image
- assigning a page to a category
- interlanguage link feature
In each case, to make an ordinary link, prefix a colon to the pagename.
Additional effects of links
edit- Related changes
- Backlinks
- Date format - since this effect applies for every link occurrence independently, a convention to avoid multiple linking to the same page within one page typically does not apply for date links.
Putting the wikitext [[Altcat:Help 2| ]] does not provide a link and only produces a blank space (perhaps depending on the browser, here it produces " "), but for "What links here" it works as a link, see Special:Whatlinkshere/Altcat:Help 2. This could be useful for a special-purpose category that should not clutter the regular list of categories a page belongs to.
See also
edit- Help:Calculation
- Help:Editing#Links, URLs
- Help:Interwiki linking
- Help:Piped link
- Help:Self link
- Help:Template#Restrictions (and the next section)
- Help:URL
- Parser testing/replaceInternalLinks
- Parser testing/replaceExternalLinks
- m:Links table
- m:Brokenlinks table
- w:Hyperlink
- w:Wikipedia:Canonicalization
Wikiquote-specific content
editLinks to other help pages
editHelp contents - all pages in the Help namespace: Meta b: c: n: w: q: wikisource wiktionary
|
External Links
edit- Special page on the Wikipedia