Most templates are pages in the Template namespace, which means that they have titles in the form "Template:XXXX". It is possible, however, to transclude and substitute from any namespace, and so some template pages are placed in other namespaces, such as the User namespace. Template pages have associated talk pages.
The prefix Template:
before the template name is the default one and need not be included. However, for templates stored in other namespaces, the prefix, such as User:
, must be specified. To transclude a page in mainspace, precede its title with a colon, as {{:Page name}}
.
The basic transclusion syntax given above can be extended by the addition of parameters, which are used to control the template's output. The syntax for this is
where template name
is the name of the template, and each parameter
may either contain just a value (these are called unnamed parameters) or be of the form name=value
(named parameters). The first, second, third, etc. unnamed parameters will be given the names 1
, 2
, 3
, etc.
Whitespace characters (spaces, tabs, returns) are stripped from the beginnings and ends of named parameter names and values, but not from the middle: thus {{ ... | myparam = this is a test }}
has the same effect as {{ ... |myparam=this is a test}}
. This does not apply to unnamed parameters, where all whitespace characters are preserved.
Which parameters (if any) can or should be passed to a template and how they are to be named depends on the coding of that template. Named parameters can be defined in any order. Superfluous or misnamed parameters will be ignored; undefined parameters will be assigned default values. If a parameter is defined more than once, the last value takes effect.
The value of a parameter can be the empty string (pipe or equals sign followed immediately by the next pipe or the closing braces). This is different from omitting the parameter altogether, which leaves it undefined, although templates are often coded so as to behave the same in both cases.
If the page to be substituted is in mainspace, the word "subst" must be followed by two colons, e.g.: {{subst::List of planets}}
Template names are exactly like other page names: case-sensitive except for the first letter, with spaces indistinguishable from underscores. If the symbol # (normally used to link to a section of a page) appears in a transclusion, then it and any characters that follow it are ignored. If a redirect is transcluded, the redirect's target will be transcluded instead. See #Aliases for more.