Getting Involved Getting Involved |
Discord Discord |
Knight Challenges Knight Challenges |
Image edit request and support center Image Requests |
Trello Boards Trello |
Guidelines:Main Guidelines |
---|
- See also: Help:Templates on MediaWiki
A template is a page made to be included in other pages. They standardize content or formats that need to be repeated on many pages, by encapsulating them in a separate page in the Template
namespace. They can abstract away complicated syntax, namely parser functions.
Templates are most often used by transclusion. That is, by enclosing the name of the template page in {{double curly brackets}}
. When placed in another page, the entire contents of that template page will be displayed where you placed it. Templates can have parameters that modify their appearance or content.
An example of a common template is an infobox, such as Template:Infobox Item. Infobox templates appear in the upper right corner of nearly every article on the wiki. There are many other types of templates.
Using Templates
Parameters
Templates can have anonymous parameters, named parameters, or both. With anonymous parameters, order matters.
Template:Item Amount is a template with anonymous parameters. It is used like this: {{Item Amount|SS|3|Ancient Flower}}
, which produces × 3 Ancient Flowers. You wouldn't get the right output if you changed the order of the parameters.
Template:Clarify is a template with both anonymous and named parameters. It is used like this: {{Clarify|BotW|reason= Some text here}}
. There's one anonymous parameter for the game, and a named reason
parameter for the display text.
Transclusion and substitution
Templates can be used by transclusion or by substitution. When you transclude a template on a page and save it, the source will still show {{<Template name>}}
when you go back to edit it. Conversely, when you substitute a template, the actual contents of the template gets copied and saved to the page.
Input | Output view | Output source |
---|---|---|
{{MM}} |
Majora's Mask | {{MM}}
|
{{subst:MM}} |
Majora's Mask | ''[[The Legend of Zelda: Majora's Mask|Majora's Mask]]''
|
In reality, Template:MM outputs something quite different when substituted, but this illustrates the point.
Generally, templates should be substituted and not transcluded. Substitution does not preserve a reference to the template—it's like you didn't use a template at all. You lose the ability to have the content update automatically when you change the template.
Making Templates
For information on how to make templates, see Zelda Wiki:Making Templates.