Template:YTURL/doc

From Angelina Jordan Wiki
This is a subpage documenting Template:YTURL. To change the template, edit that page; to change the template's documentation (seen below), edit this one.

Documentation

This template constructs URLs for YouTube links. It shouldn't really be used directly by editors but by other, more useful templates that editors can use.

The name is based on the phrase "YouTube URL".

This template is used on a great many pages. Making any changes to it will cause lots of jobs to be added to the processing queue.

Usage

  • {{YTURL}}
  • {{YTURL|path}}
  • {{YTURL|path|protocol=http: or https: or nothing}}
  • {{YTURL|path=}}
  • {{YTURL|path=|protocol=http: or https: or nothing}}

The "path" refers to everything after "youtube.com/" in the URL of the YouTube page you want to link to. If the path contains an equals sign (which is very likely), you should either "name" the positional parameter 1= in your template call (if you are trying to use the first or second form above) or use the explicitly-named parameters in the third or fourth form. Otherwise the equals sign will be interpreted as separating a parameter name from its value, resulting in a malformed link, as shown in the examples below.

Note that protocol-relative URLs are formed by default. When used to form live links, this means someone browsing the wiki in non-secure mode will get links beginning with http: and someone browsing in secure mode will get links begnning with https:. (But note that currently this wiki can only be browsed in secure mode.) This behavior can be overridden by using the protocol parameter (the value of which must include the final colon, when specified).

Examples

  • {{YTURL}} ⇒ //www.youtube.com/
  • {{YTURL|channel/UChM_lpT4shdnsez93QMJPig}} ⇒ //www.youtube.com/channel/UChM_lpT4shdnsez93QMJPig
  • {{YTURL|1=watch?v=aHGSsqQOs5I}} ⇒ //www.youtube.com/watch?v=aHGSsqQOs5I
  • {{YTURL|path=watch?v=aHGSsqQOs5I}} ⇒ //www.youtube.com/watch?v=aHGSsqQOs5I
  • {{YTURL|path=watch?v=aHGSsqQOs5I&t=5s}} ⇒ //www.youtube.com/watch?v=aHGSsqQOs5I&t=5s
  • {{YTURL|path=watch?v=aHGSsqQOs5I|protocol=http:}}http://www.youtube.com/watch?v=aHGSsqQOs5I

Notice how the protocol-relative bare URLs are not automatically linked, as seen in the first four examples, but bare URLs starting with http: or https: are autolinked by the MediaWiki software (the last example), unless they are surrounded by square brackets, as illustrated below.

Here's what the same examples look like when forming external links using square brackets:

  • [{{YTURL}}][1]
  • [{{YTURL|channel/UChM_lpT4shdnsez93QMJPig}}][2]
  • [{{YTURL|1=watch?v=aHGSsqQOs5I}}][3]
  • [{{YTURL|path=watch?v=aHGSsqQOs5I}}][4]
  • [{{YTURL|path=watch?v=aHGSsqQOs5I&t=5s}}][5]
  • [{{YTURL|path=watch?v=aHGSsqQOs5I|protocol=http:}}][6]