You've no doubt seen at least some of the many templates - navboxes, infoboxes, boilerplate warnings, tags, notices and so-one - that are everywhere on Wikipedia. You may even have used some of them yourself. This page is intended to give a brief, informal introduction to templates and how they work; for more information, see this guideline.

What is a template?

[edit]

No-one wants to spend ages typing up the same piece of information over and over again, yet on Wikipedia, it's often necessary to add generic messages to article or talk pages. For this reason, we have templates which can be used to add commonly-used messages or formats with the minimum number of keystrokes.

Templates work by copying the contents of the template page onto the page where you place the template. This is known as "calling" the template. For example, adding the text ((Like)) to a talkpage tells the software to go to the page Template:Like and copy the contents to the destination talkpage - giving you this: 👍 Like. Since the markup text of even the comparatively simple Template:Like looks like this:

<span style="display:inline-block;padding:0 .5em;line-height:1.75em;border:1px solid #CAD4E7; font-family:'Lucida Grande',Tahoma,Verdana,sans-serif; ((border-radius|3px)) background:#ECEEF5; text-align:center;">[[File:(({image|Facebook like thumb.png))}|text-top|link=|alt=👍]] <span style="color:#3B5998;">((#if:(({num|))}|(({num|))} ((PLURAL:(({num|))}|user (({1|likes))}|users (({1|like))))} this.|((#if:(({username|))}|[[User:(({username|))}|(({username|))}]] likes this.|(({1|Like))))))}</span></span>

you can see why it's preferable to simply call the template, rather than typing out the entire code.

Templates are used for a number of different purposes. Some of the most common types are as follows (a complete list can be found here):

Transclusion or substitution?

[edit]

There are two methods for calling a template:

Some templates, like ((Proposed deletion)) must always be substituted in order to work; others, like ((cleanup)), should only ever be transcluded. If you are not sure, go to the template page and check the documentation. A number of bots exist to automatically substitute templates if this has not been done, but it is always preferable to do the work yourself.

Parameters

[edit]

Many templates can be customised to give tailored information. For example, the ((uw-vandal)) template is a warning for vandalism, and produces the following when used (substituted):

Hello, and welcome to Wikipedia. Although everyone is welcome to contribute to Wikipedia, at least one of your recent edits did not appear to be constructive and has been reverted or removed. Please use the sandbox for any test edits you would like to make, and read the welcome page to learn more about contributing constructively to this encyclopedia. Thank you.

However, if the user being warned has edited several articles, it can be helpful to specify which article has been vandalised. To do this, we add the problem article as an additional parameter, using a pipe: ((subst:uw-vandal|Sausage)), for example, gives us this message:

Hello, and welcome to Wikipedia. Although everyone is welcome to contribute to Wikipedia, at least one of your recent edits, such as the one you made to Sausage, did not appear to be constructive and has been reverted or removed. Please use the sandbox for any test edits you would like to make, and read the welcome page to learn more about contributing constructively to this encyclopedia. Thank you.

It is also possible to use multiple parameters, again separated by pipes. The ((uw-vandal)) template allows for additional text as a second parameter, so typing this: ((subst:uw-vandal|Sausage|It is not appropriate to discuss the size of your sausage on Wikipedia.)) gives this:

Hello, and welcome to Wikipedia. Although everyone is welcome to contribute to Wikipedia, at least one of your recent edits, such as the one you made to Sausage, did not appear to be constructive and has been reverted or removed. Please use the sandbox for any test edits you would like to make, and read the welcome page to learn more about contributing constructively to this encyclopedia. It is not appropriate to discuss the size of your sausage on Wikipedia.

Each template page provides a list of available parameters in its documentation (see Template:Uw-vandal1 for the example above). Some templates use named parameters; for example, the ((cite book)) template uses parameters such as |title=, |publisher= and |page=. In such cases, place the information to be displayed after the = sign.

Creating templates

[edit]

Although templates can have quite complex code, they can be created by any user.