From Heroes Wiki
Jump to: navigation, search

General Help
Special Topics
For more help...

Contact an administrator

Or leave a message

Templates are used to create special formatting or consistent elements in articles. Templates allow formatting changes to be made to the template, and automatically have those changes reflected in all articles which include that template.

Using Templates

To include a template in a page, enter {{name_of_template}} in the page where you would like to include the template. If a template accepts variables, enter them using a pipe, the name of the variable (if any), an equals sign, and the text you wish to use. For example, {{template|text=your_text_here}} would insert the template "template" and set the variable "text" to "your text here".

For usage notes for a particular template, including any variables, see each template's article.


You can also include an article as if it were a template by placing the article's name, preceded by a colon, in double braces. For example, typing {{:Niki Sanders}} would insert the text of Niki's article into the article you are editing. If Niki's article is changed, the changes will be automatically reflected on the page in which it is included.


Finally some templates are meant to be substituted. A substituted template copies the template's text into the article as text, not as a reference back to the template. It basically just 'pastes' the content of the template into the article. To substitute a template, enter {{subst:template_name}} and hit "save page". When the edit is completed, the text from the template will appear in the article.

Adding a Template

To add a template, create it just like any other article, but be sure to name it with the Template: namespace.

Markup for inclusion

Some special Wiki markup controls how the text you add to a template article will be treated when the template is included.

  • <noinclude>: Any text between the tags will appear in the template's article but not be included when the template is added to pages. Useful for assigning category to the template but not the article or for typing usage notes for the template.
  • <includeonly>: Any text between the tags will appear in when the template is added to an article but not in the template's page itself. Useful for assigning category to the article but not to the template.


Templates can use variables, either specific to the template or global.

Template-specific Variables

Enclose variables in triple braces where you would like them to appear in the included template. Be sure to list and explain any variables in the Usage section so other editors will know what variables they can feed to the template. Be mindful of capitalization and spelling of variables to make sure your template functions properly.

Global Variables

Global variables are a little different. Basically, they are system-defined templates that can be used in any article. You can use global variables to insert things like the current page's name, the date and time, or the total number of articles. They are used like templates—that is, in double braces rather than triple braces. For a complete list of available global variables, see Wikipedia Help: Variables.


Templates (and other articles) can make use of a set of special templates called conditionals. A conditional tests whether a specified condition exists and then displays different text based on the result. For example, in a template you can use a conditional to see if the editor has specified a particular variable in the template call. If they have, you can print the appropriate information. If not, you can skip the info or print a different default message.

To use a conditional, enclose it in double braces. Pipe each value required by the conditional. Insert a pipe at the end of any variables you are testing. For example

{{#if: {{{image|}}} | [[Image:{{{image}}}]] | No Image Available}}

checks to see if the template call specified a value for image. If it finds one, it prints the image. If it does not, it prints "No Image Available" instead.

For a list of all available conditions, as well as more detailed help, please see WikiMedia Help:ParserFunctions.

The Usage Section

Be sure to add a usage section to your template so others will know how to use your template. Begin you usage section with a <noinclude> tag to prevent it from being included in articles which call the template. The <noinclude> tag should be placed immediately after the text of your template with no line breaks or spaces; otherwise, the additional formatting will be included when the template is called.

After the tag, break the line and add a section heading for Usage. Explain what your template does, and any special properties it has (such as clearing floated images or adding categories when it is included).

You should then give an example of use. Put this inside a pair of <pre> tags. This will preserve formatting, prevent the wiki markup from being executed, and allow users to cut and paste the blank example of your template. A completed example should look like this:

{{Tim's Template
| Name = <!-- Variable for Name -->
| Quest = <!-- Variable for Quest -->
| Favorite Color = <!-- Variable for Favorite Color -->
| Airspeed = <!-- Airspeed velocity of an unladen swallow.  Specify African or European -->

Note that the explanations of the variables are enclosed in comment tags (<!-- -->). That way, if an editor forgets to remove your default text when pasting in the template, your default won't accidentally appear in the article.

Finally, your usage section should include [[Category: Templates]]. That way, all templates are listed together in the category for easy reference.

Commonly Used Templates

A list of commonly used templates may be found here.