Template:Link if exists
| This template is used on approximately 292,000 pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
| Due to a server limit of 500 "expensive parser function" calls (e.g. #ifexist:, PAGESIZE:, and PAGESINCATEGORY:), this template will only work properly if the page using it has not already exceeded the limit. When the limit is exceeded, the page using this template or module is categorised in Category:Pages with too many expensive parser function calls. (further information) |
| This template uses Lua: |
Usage
[edit]Positional parameters
[edit]- 1
- Title of page to link to. Wikilinked if an article exists, otherwise unlinked.
- 2
- (optional) Text to display, defaults to positional parameter 1
Named parameters
[edit]- nsp
- The namespace to try to link to (e.g.,
|nsp=Category). This namespace is not displayed. - prefix
- A string to prefix the link. This prefix is displayed if a link is found.
- color
- Color of text if no link is found
- hide_display
- If page does not exist and if hide_display is non-empty, do not display anything
Examples
[edit]- A page which exists:
{{Link if exists|Japan}}→ Japan - A page which does not exist:
{{Link if exists|The exciting story of paint drying in a small town in Japan one day in April 1927}}→ The exciting story of paint drying in a small town in Japan one day in April 1927 - Another page which exists, prefix specified:
{{Link if exists|History|prefix=Portal}}→ Portal:History - A page which does not exist, nsp specified:
{{Link if exists|Computing in 1066|nsp=Portal}}→ Computing in 1066 - Use of second positional parameter, page exists:
{{Link if exists|target|word}}→ word - Use of second positional parameter, page does not exist:
{{Link if exists|agrp|,asmd}}→ ,asmd - Page does not exist, color parameter:
{{Link if exists|agrp|color=#888}}→ agrp - Page does not exist, hide_display parameter:
{{Link if exists|agrp|hide_display=1}}→
See also
[edit]- {{Link if not current}}
- {{Linked}} – links if not already linked
TemplateData
[edit]This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Link if exists in articles based on its TemplateData.
TemplateData for Link if exists
Link to a page if it exists, otherwise leave unwikilinked
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Title | 1 | Title of page to link to | Page name | required |
| Display | 2 | Text to display
| String | optional |
| Namespace | nsp | The namespace of the title to link to
| String | optional |
| Prefix | prefix | String to add a prefix to the title
| String | optional |
| Color | color | HTML color of text if no link is displayed | String | optional |
| Hide display | hide_display | If non-empty, hide display string if not existing | Boolean | optional |