User:AtteSmythe/Cleanup/Using templates

''Editors: Please note that this page does not actually require cleanup. It was merely a familiar template to use''

Once you know some basic Mediawiki code and have practiced it for a while, read on. You should be familiar with basic editing before going on.

The idea of a template is not very complicated: Using a template takes code from one page and puts it into another page. That's it! The yellow message box at the top of this page is a template. Another way to think of templates is to consider them like form letters. All the bits that are going to be the same on every page it's used are in it, and you just fill in the blanks.

Using Templates
It's important to note that templates are created by other wiki editors, and just like when editing pages, many editors have their own style of template. Most templates have usage notes on their page or on their talk page. Look there to find out how to use the template, but if there are no usage notes, you'll have to ask for help on the talk page or look at the source and figure it out for yourself. Template creation is for another article, however; for now, let's consider a few simple templates.

Simple templates
Using a template is much like making a link. To make a link to a simple template, Template:Cleanup, is done like for any other article, like this: Template:Cleanup. To include the contents of the cleanup template into the page, simply replace the square brackets  around the link with curly brackets , like this:. Doing so yields the following: The most commonly-used templates are in a special 'namespace' called, intuitively, Template. The wiki software knows this, so you can leave out the Template namespace, and use just the page name. To continue using our example, the code would end up being

Template Parameters
The more complicated a template is, the more information it requires from an editor. We've been using the cleanup template as an example. If you look at its source, though, it is also based on a template: Template:Message box. The same messagebox template is at the top of this page, informing you that this is not official documentation. They look very dissimilar, but you should see some things in common: If you look at the usage notes at the bottom of the message box template's page, they confirm that these are the four basic parameters: backgroundcolor, image, heading, and message. Using template parameters is like renaming a link, you use the | symbol inside the brackets. After the pipe, put the name of the parameter, an equals sign ( = ), and what you want to use for that parameter.
 * They are centered
 * They have borders and coloured backgrounds
 * They have an image on the left
 * They have a bold heading, and a smaller, normal text message.

Here's the code for a simple message box: It's kind of a mess - long, unreadable, just a stream of letters. Template parameters do not have to be placed on their own line, but they can be, if it makes the page source more readable. Consider the same template with the same parameters, but looking like this: The format is exactly the same, only there is a newline put in before each new parameter. The | character is at the beginning of the line, and it may seem unintuitive to put it there, but you can see that it still separates each parameter from the one before it. Putting the | at the beginning of the line makes it less likely that someone editing the text later will accidentally delete it.

Both code examples, above, produce the following template:

Finding Template Help
As noted above, most templates have help on the template's page or talk page. An easy way to find a link to a template is to go to the edit screen of a page using that template. Below the edit box, there will be a list of templates being used on that page. Just click one of those links to read the usage notes.

More advanced templates will include templates of their own, sometimes very many, and the list of templates in use can be pretty long. Just find the name of the template in the page source, then look for it below the edit box. If a template has you completely daunted, feel free to use the helpme or helpmewith templates on the page you're editing. They'll let other editors know that you'd like some help.