Help:Templates
| Contents | Introduction | Guidelines | Markup | References | Images | Categories | Templates | What's Next? |
Introduction
Templates are a customizable tool that can make complex editing easier to do by creating a shortcut. This means that instead of rewriting complex elements every time you need it, you can use a simple text tag that will do (most) of the work for you. In this article we'll go over the basics of using templates, some useful templates that are built in, and an introduction to creating your own templates. For a more in depth guide on templates, check out Mediawiki's Help article.
Basics of Templates
Templates are easy to recognize as they are enclosed by double curly braces. ({{ and }}) To use one you must first indicate the name of the template you want to use, and then define various parameters. All of the elements between the double curly braces are separated by vertical bars. (|) The number and type of parameters will vary depending on the template.
Some templates will be written in a single line of text, but some may span multiple lines. The more complex it is, the more likely it spans multiple lines. This is to help with clarity in usage. For example:
| A Single Line Template | A Multi-Line Template |
|---|---|
{{template name|parameter1|parameter2|parameter3}}
|
{{template name
|parameter1
|parameter2
|parameter3
}}
|
Parameters
Parameters come in two varieties: Named and Unnamed. Templates will use one or the other, or even sometimes both. You can see the exact parameters a template uses by checking out its template page.
- Named Parameters
- Named parameters can be recognized by their use of an equals sign (
=), which is required with a named parameter. The equals sign is followed by your input. For example:{{template name|parameter1=INPUT}}
- In this example
parameter1=is a named parameter because of its use of an equals sign.INPUTwould be replaced by your input.
- Unnamed Parameters
- Unnamed parameters should be completely replaced by your input. For example:
{{template name|INPUT}}
- In this example
INPUTis an unnamed parameter. Note that no other text is required beyond your input.
Example
Let's take a look at some templates in action.
| Example: Named Parameters | ||||||||
|---|---|---|---|---|---|---|---|---|
| This example makes use of an infobox template, which exclusively uses named parameters. | ||||||||
| You Type | You Get | |||||||
{{character
|name=Pen
|image=Pen.png
|caption=Image Caption Here
|introduced=First Appearance
}}
|
||||||||
| Example: Unnamed Parameters | ||||||||
| This example makes use of an infobox, which uses exclusively named parameters. | ||||||||
| You Type | You Get | |||||||
{{quote|My existence of the last three years has been nothing but incident.|Emma M. Lion}}
|
} Types of TemplatesLet's go over the common types of templates you may encounter and make use of. Information BoxesCalled infoboxes for short, these templates create the tables at the upper right hand corner of articles. They display important facts and details which are common to articles of the same category. Infoboxes are placed at the start of the article. There are infobox templates for all of the high level content categories, and a few others that are more specific. Common examples include For more detailed help on infoboxes in general see Help: Infoboxes and for a full list of infobox templates, see Category: Infoboxes. Called navboxes for short, these templates create the tables at the bottom of pages that link to other important articles that are related to the same book or series. Most series or standalone books have a navbox that refers to important characters, places, etc. Navboxes are placed at the end of the article, directly after the For a full list of navbox templates, see Category:Navbars. NoticesNotice templates alert users and editors of important information regarding the page itself. Some notable notice templates are listed below. For a full list of notice templates, see Category:Notices.
Reference TemplatesReference templates are used to cite the source of information in an article. They create a superscript number that links to the footnotes in the "Notes" section, where the full reference is provided. For more on reference templates, see Help:References. Link MacrosLink macros are templates which link to something that's related to the input. They often categorize the article as well. For a full list of link macros, see Category:Link macros. Editorial NotationsEditorial notations are used to highlight information which is unsupported, ambiguous, or questionable. For more, see Help:References. Other TemplatesSome other notable templates include the following:
Do or do not. There is no try. ” —Yoda
Template PagesTemplates are created just like articles and categories: you create a page for one in the Template namespace. You should find documentation for a template on this page. It will provide a description of what the template does, a list of required and acceptable parameters, and occasionally some examples. Editing TemplatesEditing templates (or creating one from scratch) is definitely not a task for beginners. But we'll go over some of the basics. Includeonly and Noinclude
Parameters
Parser FunctionsThere are a number of functions that can be used to generate different results based on the input provided. For an extensive list, see MediaWiki's Parser Functions page. Here are some of the basics:
System VariablesThere are a few system variables which provide different values as needed. These are given in all caps between double curly braces. For an extensive list, see MediaWiki's Magic Words page. The two most common are:
CommentsComments inside of Note: You might see a lot of these in existing templates, at the beginning and end of each line. White space can do strange things in templates, and so it is best to eliminate unnecessary white space by putting it inside of comments. One notable exception is inside tables, between the
|
|||||||
