Help:Template

Jump to: navigation, search
Styling of content happens through Templates. There are 2 kinds, templates for a specific kinds of articles and templates for styling of recurring content in articles.

Usage

Templates are used to add recurring messages to pages in a consistent way, to add boilerplate messages, to create navigational boxes and to provide cross-language portability of texts.

The content of a template can be added to a page by typing {{templatename}}.

Templates should be used

  • To display important notices or messages
  • To ensure consistent look and feel across the wiki
  • To ease editing when the same text is repeated in a great number of articles
  • To tag an article when doing maintenance operation

Templates should not be used

  • To create lists of links to other articles when a category or a See also list can perform the same function.

Standardized templates

See Standard templates for a list of standard template messages.

We also have standard template pages for different use cases:

Creating new templates

Icon-warning.png
Warning: If possible, do not create new template apart from new navigation bar.

Please observe these rules when creating a new template which is absolutely required:

  • Template title must start with Template:.
  • Templates are case sensitive, except the first letter.
  • Template name must follow the naming conventions. In short, only the first letter is uppercase and CamelCase is not allowed.
  • Template can be moved to a new name. The redirect target will be included instead of the redirect page itself.
  • Template can be used within other templates.
  • Icon size should be 32px.
    • In rare case when template is larger, use then 48px or 64px.
    • If icon takes too much space in tables, then put style="width:32px" in cell before icon and size will be reduced to 32px.
  • Template width should be width:100% of page width. If it should be smaller then check text flow around the template.
  • Text position should be placed on the left. Text that is not aligned to start from the same position is harder to read as eyes have to locate begin, and if that happens on every line, it makes very unpleasant experience.

For other questions regarding templates, refer to Wikipedia Help:Template article. See also ParserFunctions to access to other advanced functioning help pages.

Template documentation

Every template must be documented in separate /doc subpage. For instance, the documentation of Template:Info is on Template:Info/doc subpage. Template documentation source should look like:

* '''Code:''' <code><nowiki>{{</nowiki>[[Template:Info|Info]]|Info text<nowiki>}}</nowiki></code>
* '''Description:''' Add important information.
* '''Where:''' Anywhere
* '''Related templates:''' [[Template:Warning|Warning]], [[Template:Forbidden|Forbidden]]
<noinclude>
[[Category:Template documentation]]
</noinclude>

The Code: tag explains what code the editor has to write to use the template, eventually with arguments. Code:, together with Description: and Where: are mandatory tags in template documentation, while Related templates: is optional and should be used only if it makes sense for given template. Do not forget to add the documentation into Category:Template documentation using <noinclude> tags.

To display the template documentation on the template page, following code snippet has to be appended to the template:

<noinclude>
{{{{PAGENAME}}/doc}}
</noinclude>

There is one exception to the rule that every template has be documented using /doc subpage. These exceptions are boilerplate templates, which are not intended to be transcluded into other pages, but rather substituted when creating new page. Examples of such pages are Template:Article, Template:Userpage or Template:Portal.

Template categorization

Every template should be put into one or more subcategories of Category:Templates. If you don't know to which category your new template belongs or if you think that you need new template category, you should ask on the wiki mailing list first.

See also Special:UncategorizedTemplates.


External links