Help:Pipe trick
The pipe trick uses the pipe character ("|") to save typing-in the right hand side of a piped link for several kinds of wikilinks. This can reduce typos in these links.
When the last character of a link is the pipe character, the pipe trick will automatically generate the text that displays for that link. This is done when the page is saved. It removes the parenthesized part of the link title, but it also processes commas in the title and Namespace prefixes. It does not have effects on the number sign ("#") (used to link directly to an article section). The pipe trick does not work in edit summaries, or within <ref> tags.
Contents |
[edit] Examples
This technique may be hard to follow, so please see the following examples:
| Type this | Generates this when you "Save page" | Appears as |
|---|---|---|
| Article titles | ||
[[pipe (computing)|]] |
[[pipe (computing)|pipe]] |
pipe |
[[Pipe (computing)|]] |
[[Pipe (computing)|Pipe]] |
Pipe |
[[Boston, Massachusetts|]] |
[[Boston, Massachusetts|Boston]] |
Boston |
[[The Lord of the Rings: The Fellowship of the Ring (video game)|]] |
[[The Lord of the Rings: The Fellowship of the Ring (video game)|The Fellowship of the Ring]] |
The Fellowship of the Ring |
| Redirection | ||
[[Bush (43)|]] |
[[Bush (43)|Bush]] |
Bush |
[[Bush (41)|]] |
[[Bush (41)|Bush]] |
Bush |
| Normal titles | ||
[[Wikipedia:Help|]] |
[[Wikipedia:Help|Help]] |
Help |
| Users | ||
[[User:Example|]] |
[[User:Example|Example]] |
Example |
| Sections This describes forthcoming changes, they do not work on Wikipedia as of April 19, 2011[update]. | ||
[[#Examples|]] |
[[#Examples|Examples]] |
Examples |
[[#History (pre-war)|]] |
[[#History (pre-war)|History]] |
History |
Subpages This describes forthcoming changes, they do not work on Wikipedia as of April 19, 2011[update]; use [[/Archives/]] instead (trailing slash and no pipe, see #Slash trick below). |
||
[[/Archives|]] |
[[/Archives|Archives]] |
Archives |
[edit] Combinations
The basic rule when the pipe trick is used is that an (initial) namespace prefix, a final part beginning with a comma, or a final parenthesis (usually intended for disambiguation) is suppressed in the rendering of the link. The rendered text is case neutral and so should be entered precisely as the user wishes it to appear in the article. In case of combinations of suppressible parts, the following rules apply:
[edit] Parentheses beat commas
If the link name involves both one or more commas and a final parenthesis, only the parenthesis is suppressed:
[[Yours, Mine and Ours (1968 film)|]]
is shown on the page as:
[edit] Only one prefix suppressed
If there are several prefixes, which can occur, for example, for an interlanguage link, only the first is suppressed:
[[:es:Wikipedia:Políticas|]]
is rendered as:
[edit] The first comma counts
If there are several commas, only the part up to the first comma is shown:
[[Il Buono, il Brutto, il Cattivo|]]
results in:
[edit] Other combinations
For the rest, if there is both an initial part and a final part that can be omitted, both are suppressed:
[[Wikipedia:Manual of Style (Persian)|]]
produces:
[edit] Where it does not work
[edit] Cite.php <ref> footnotes
- This limitation has been removed in the development version of the software, and so the following will not be broken in the future. However, it does not yet work, as of April 19, 2011[update].
The trick does not work when enclosing between "ref" tags.
renders in the references list (generated by the <references/> tag) as:
- ^ [[Roger Taylor (author)|]]
[edit] Edit summaries
The trick does not work in edit summaries. /* Edit summaries and the pipe trick */ as tested in [[WP:SAND|]] renders in the edit history as:
(→Edit summaries and the pipe trick: as tested in WP:SAND)
[edit] Section links
- Currently:
The pipe trick does not work on section links, and in general it does not work for links to anchors (links that use a # sign). For example, [[Wikipedia:Verifiability#Sources|]] does not give you a clickable wikilink "Verifiability#Sources" but results in:
- [[Wikipedia:Verifiability#Sources|]]
- Future behaviour, not valid as of April 19, 2011[update]:
The pipe trick works only for section links to the current page. While [[#Examples|]] gives [[#Examples|Examples]]; [[Other#Examples|]] acts like [[Other#Examples]]
[edit] Slash trick
You can achieve the same effect for subpages by adding a slash: [[/subpage/]] generates the same output as [[/subpage|subpage]]. Unlike the pipe trick, though, it will not be transformed in the wikitext.
This trick only works in namespaces where [[/subpage]] would.
[edit] Reverse pipe trick
If the title of the article containing the link includes a parenthesized term or a comma, placing a pipe at the start of the link will append the corresponding text. For example, if the link [[|Agonizer]] were placed in Agonist (disambiguation), the link would be expanded to [[Agonizer (disambiguation)|Agonizer]]. Using the reverse pipe trick on an article that has no parentheses or comma in its title is unproductive; the pipe character is automatically removed. The reverse pipe trick does not work with colons.
[edit] Try it!
The best way to understand this when editing a page, is to try it yourself with the "Show Preview" or "Show Changes" buttons; or you can try it in the sandbox: use one of the examples under "Type this" above, save the sandbox page, then immediately edit it again. You'll see the transformation, and it might be more clear exactly what happened.