Template:YTURL/doc

From Angelina Jordan Wiki
Revision as of 11:21, 9 August 2022 by Dcljr (talk | contribs) (+ {high-usage-template warning})
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 (as seen at the top of this page). This means someone browsing the wiki in non-secure mode will get links using http: and someone browsing in secure mode will get links using https:. (But note that currently this wiki can only be browsed in secure mode.) This behavior can be overridden by using the protocol parameter.

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

Note how you must include the trailing colon (:) when specifying a protocol, as seen in the last example (since allowing otherwise would impose a small speed penalty on calls to the template, as it checks for the presence of a colon). Also, notice how the protocol-relative bare URLs (meaning those not between [square brackets] or [[double square brackets]]) are not automatically linked, as seen in the first four examples, but bare URLs starting with http: or https: are autolinked (last example). This is only an issue when the output of the template is shown as regular text, rather than being used inside of a link.

For comparison, here's what these 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]