Template:YTURL/doc
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".
Usage
{{YTURL}}{{YTURL|path part of URL}}{{YTURL|path part of URL|protocol=http: or https: or nothing}}{{YTURL|path=path part of URL}}{{YTURL|path=path part of URL|protocol=http: or https: or nothing}}
The "path part of URL" means everything after "youtube.com/" in the URL of the YouTube page you want to link to. If the path contains the equals sign (highly likely), you should probably use one of the last two forms shown above; otherwise, each equals sign would have be to "escaped", 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:. This behavior can be overridden by using the protocol parameter.
Examples
{{YTURL}}⇒ //www.youtube.com/{{YTURL|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 the equals sign must be "escaped" in the second example by using {{=}}. This is not necessary when using the named parameter path, as in the other examples. Note also that you must include the trailing colon (:) when specifying a protocol (doing otherwise would impose a small speed penalty on calls to the template). Finally, 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).
For comparison, see what these look like when forming links using square brackets: