Help:Piped link

From The Scuba Wiki

Jump to: navigation, search
MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins +/-

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 box and is also shown in the status bar.

For instance:

[[coffeehouse setup|How to set up a coffee house]]

will show: How to set up a coffee house

Another example would be [[train station|station]] rendering as station. This is useful where the word "station" is used in an article on trains; from the context, it would be clear that a train station is meant. The piped link is more convenient to the user than a link to station which might be a disambiguation page.

The term piped refers to the use of the pipe character "|" used to separate the good description from the actual link. This character is named after an alternative use of it; see Pipe (computing).

Contents

Using a redirect as an alternative

An alternative is simply using redirect pages. To create How to set up a coffee house, use [[How to set up a coffee house]] and make this a redirect to coffeehouse setup (note that, unlike above, what pops up when you point at the link, if applicable for your browser, is simply the text already shown).

This is convenient if the redirect is already there or will also be of use elsewhere; however, there are a few drawbacks:

  • the popup does not show the page one will arrive at
  • "Related changes" gives the changes in the redirect page not the redirect target
  • the redirect message on the target page slightly clutters it

Combining a piped link and a redirect, one can provide some information that is not the name of the page one links to in the hover box, such as the value of a unit in terms of other units. In that case one can make a page whose pagename is the info one wants in the link title, and which redirects to a page with a more appropriate name. See e.g. w:Template:Ft, containing [[30.48 cm|ft]], with the page w:30.48 cm redirecting to w:Foot (unit of length).

Automatic conversion of the wikitext

Pipe trick

If in a piped link the part after the "|" is left empty, it is converted to an abbreviated form of the page name on the left, 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 is removed

Just like for the three or four tildes when signing on Talk pages and the use of subst, 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.

Examples

  • [[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
  • [[commons:Boston, Massachusetts|]] is converted to [[commons:Boston, Massachusetts|Boston]], which is rendered as Boston.
  • [[w:{{{1}}}|]] does not give [[w:{{{1}}}|{{{1}}}]], and 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}}]] and [[m:{{FULLPAGENAME}}|]] does not give [[m:{{FULLPAGENAME}}|{{FULLPAGENAME}}]]
  • [[Wikipedia:Village pump (technical)#Pipe trick|]] is not converted, so does not give a working link
*[[project:a (b)|]]
*[[w:project:a (b)|]]
*[[:de:project:a (b)|]]
*[[wiktionary:project:a (b)|]]
*[[wiktionary:de:project:a (b)|]]
*[[wikibooks:project:a (b)|]]
*[[wikiquote:project:a (b)|]]
*[[wikisource:project:a (b)|]]
*[[w:en:{{FULLPAGENAME}}|]] [[w:en:{{FULLPAGENAME}}|en:{{FULLPAGENAME}}]]
*[[m:{{FULLPAGENAME}}|]] [[m:{{FULLPAGENAME}}|{{FULLPAGENAME}}]]

produces

Category tag

The sortkey syntax of the category being like a piped link, the pipe trick also works for category tags, even though it is not useful there.

Limitation

  • [[Help:L{{tc}}k|]] using template:tc ( talk edit history links ) is not converted, so the result is rendered as [[Help:Link|]] and not as a working link. This is because the pipe trick expansion, like substitution, occurs before ordinary expansion of templates, etc., while the pipe trick does not work if the linked page contains invalid characters. Thus while ordinarily the acceptability of the target page name is judged after template expansion, the pipe trick expansion judges it before, the braces are considered invalid characters in the page name. Instead one can use a template like template:pipe trick ( talk edit history links ): {{pipe trick|Help:|L{{tc}}k}} gives Link.

Inverse pipe trick

On page "A (c)", [[|b]] is automatically converted to [[b (c)|b]].

Similarly, on page "A, c", [[|b]] is automatically converted to [[b, c|b]].

Syntax for external links

For external links a space is used instead of a pipe character; see Help:Editing.

See also


+/-

Links to other help pages

Help contents
Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary | commons: | mw: | b: | s: | mw:Manual | google
Versions of this help page (for other languages see below)
Meta | Wikinews | Wikipediahttp://en.wikipedia.org/Help:Piped_link | Wikiquote | Wiktionary
What links here on Meta or from Meta | Wikipedia | MediaWiki
Reading
Go | Search | Stop words | URL | Namespace | Page name | Section
Backlinks | Link | Piped link | Interwiki link | Redirect | Category | Image page
Logging in and preferences
Logging in | Preferences | User style
Editing
Advanced editing | Editing FAQ | Edit toolbar | Export | Import | Shortcuts
Tracking changes
Recent changes (enhanced) | Related changes | Watching pages | Diff
Page history | Edit summary | User contributions | Minor edit | Patrolled edit
Style & formatting
Wikitext examples | Reference card | HTML in wikitext | List | Table | Sorting | Colors
Special input and output
Inputbox | Special characters | Displaying a formula | Images (uploads) | EasyTimeline
Advanced functioning
Template | Advanced templates | Parser function | ParserFunctions | Parameter default
Variable | Magic word | System message | Substitution | Array | Calculation
Page management
Starting a new page | Renaming (moving) a page | Protecting pages | Deleting a page
Special pages
Talk page | Testing | Sandbox | CentralNotice

Template:-

Personal tools
support the site