Template:URL: Difference between revisions
mNo edit summary |
Show full URL if we have a prefixed protocol |
||
Line 8: | Line 8: | ||
|http:/ | |http:/ | ||
|ftp:/=<!-- Matches https:/ or http:/ or ftp:/ | |ftp:/=<!-- Matches https:/ or http:/ or ftp:/ | ||
-->[{{#if:1|{{{1|}}}}} <!-- This #if:1 allows trimming leading spaces in the full URL: {{{1|}}} | -->[{{#if:1|{{{1|}}}}} {{#if:1|{{{1|}}}}} <!-- This #if:1 allows trimming leading spaces in the full URL: {{{1|}}} | ||
-->]<!-- | -->]<!-- | ||
-->|#default=<!-- Not https:/ or http:/ or ftp:/ | -->|#default=<!-- Not https:/ or http:/ or ftp:/ |
Latest revision as of 19:09, 18 June 2022
This template creates 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.
Note: If you wish to display text instead of the URL (e.g. website instead of http://example.com), please do not use this template. Instead, consider using normal wiki markup.
Usage
{{URL|example.com}}
- The first parameter is parsed to decide whether it is a complete URL. If it doesn't start with a URI scheme (such as "http:", "https:", or "ftp:"), the prefix "http://" is prepended to the specified generated target URL of the link.
URL with = character should use numbered parameters
If the URL contains an equals sign, as is common in a query string, the parameter |1=
should be used for the URL ({{URL|1=example.com}}
). 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
{{URL|1=https://example.com/?id=42}}
The template attempts to handle simple cases where a URL containing an equals sign is specified without the necessary |1=
, but it is still better practice to pass it in.
The above documentation is transcluded from Template:URL/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |