Changes

Jump to navigation Jump to search
→‎Examples: Update examples to include actual output by the template, including <span>...</span> and <wbr/> tags.
{{Documentation subpage}}
{{lua|Module:URL}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->

This template can be used to create a formatted external link. It formats the appearance of '''''displayed''''' URLs, while making them ''machine-readable'' as part of emitted [[microformat]] meta-data, inside templates such as infoboxes.

If you wish to display text instead of the URL (e.g. "[http://example.com website]" instead of {{URL|example.com}}), please '''do not use this template'''. Instead, consider using normal [[Help:Link#External_links|wiki markup]] or [[Template:Official website]]. Displaying text instead of the url will render the microformat data invalid.

For web-based references, please see [[Wikipedia:Citation templates]].

== Usage ==
* <code><nowiki>{{URL|</nowiki>''example.com''<nowiki>}}</nowiki></code>
** The first parameter is parsed to see if it takes the form of a complete URL. If it doesn't start with a URI scheme (such as "http:", "https:", or "ftp:"), an "http://" prefix will be prepended to the specified generated target URL of the link.
** Parameter 2 (<code><nowiki>{{URL|</nowiki>''url name''<nowiki>|</nowiki>''optional display text''<nowiki>}}</nowiki></code>) is '''deprecated'''. See note above for more information and alternative templates.

===URL with {{=}} character requires numbered parameters===
If the URL contains an equals sign, as is common in a query string, the parameter {{para|1}} must be used for the URL (<code><nowiki>{{URL|</nowiki>1=''example.com''<nowiki>}}</nowiki></code>). This applies when the value of the URL is unknown, for example when this template is used in another template specifying the effective URL as a variable value. The ''deprecated'' second parameter for the displayed text, if present in legacy uses, '''must''' also be explicitly numbered if the first parameter is explicitly numbered (<code><nowiki>{{URL|</nowiki>1=''url name''<nowiki>|</nowiki>2=''optional display text''<nowiki>}}</nowiki></code>); otherwise it will override the value of the first parameter.

{|class="wikitable"
|-
! Code !! Result
|-
| <code><nowiki>{{</nowiki> {{BASEPAGENAME}} <nowiki>| 1=https://example.com/?id=42 }}</nowiki></code>
| {{ {{BASEPAGENAME}} | 1=https://example.com/?id=42 }}
|-
| <code><nowiki>{{</nowiki> {{BASEPAGENAME}} <nowiki>| 1=https://example.com/?id=42 | 2=Title }}</nowiki></code>
| {{ {{BASEPAGENAME}} | 1=https://example.com/?id=42 | 2=Title }}
|}

=== Examples ===
To the right of each example is the displayed output. Below each example is the actual output including {{tag|span}} and <code>&lt;wbr/></code> tags.
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | EXAMPLE.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | example.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | http://example.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | www.example.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | http://www.example.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | https://www.example.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | ftp://www.example.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | ftp://ftp.example.com }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | http://www.example.com/ }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | http://www.example.com/path }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | irc://irc.example.com/channel }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | www.example.com/foo }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | http://www.example.com/path/ }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | www.example.com/foo/ }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | 1=http://www.example.com/path?section=17 }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | 1=www.example.com/foo?page=42 }}</nowiki>}}
{{nowiki template demo|format=inline|output=nowiki+|code=<nowiki>{{URL | www.example.com | example.com }}</nowiki>}}

== Microformat ==
The template wraps the ''displayed'' URL with a <code>class="url"</code> so that it is included in any parent [[microformat]] which takes a URL parameter - see [[WP:UF|our microformats project]].

== TemplateData ==
{{TemplateDataHeader}}
<templatedata>
{
"description": "A template to display and format a URL, inside other tempates",
"params": {
"1": {
"label": "URL",
"description": "The URL to be linked",
"type": "string",
"required": true
},
"2": {
"label": "Display text",
"description": "The text to be displayed instead of the URL. Deprecated",
"type": "string",
"required": false,
"deprecated": true
}
}
}
</templatedata>

== See also ==
* {{Tl|Official URL}}
* {{Tl|Official website}}
* {{Tl|Plain link}}

<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:External link templates]]
}}</includeonly>
Anonymous user

Navigation menu