Wikipedia:Template namespace

From Wikipedia, the free encyclopedia
  (Redirected from Wikipedia:NS10)
Jump to: navigation, search
For learning how templates work, see Help:A quick guide to templates and Help:Template.
For extended technical information, see m:Help:Template and m:Help:Advanced templates.
Wikipedia namespaces
Subject namespaces Talk namespaces
0 (Main/Article) Talk 1
2 User User talk 3
4 Wikipedia Wikipedia talk 5
6 File File talk 7
8 MediaWiki MediaWiki talk 9
10 Template Template talk 11
12 Help Help talk 13
14 Category Category talk 15
100 Portal Portal talk 101
108 Book Book talk 109
118 Draft Draft talk 119
446 Education Program Education Program talk 447
710 TimedText TimedText talk 711
828 Module Module talk 829
Virtual namespaces
-1 Special
-2 Media

The Template namespace on Wikipedia is used to store templates, which contain Wiki markup to be included on several pages via transclusion. The main function of templates placed in this namespace are to maintain consistent formatting and aid navigation between articles, and usually include several optional elements controlled by parameters to allow for specialized use. Templates are also used to assist in a large variety of Wikipedia maintenance tasks.

Pages in the Template namespace can be identified by template tags, which use double curly braces such as {{Disambiguation}} to indicate they are being called as transcluded elements. They can also be identified by the Template: prefix (for example [[Template:Disambiguation]]), which indicates a link to a page that directly contains a base template.

Each template has a matching Template talk: page where editors can discuss the design and implementation of the associated template (see Help:Using talk pages for how to participate in talk page discussions).

Searching for templates[edit]

Use this form to search in the Template: or Template_talk: namespaces. See Help:Searching for more information.

Pages which contain information on commonly used templates:

If you're unable to find an existing template for your situation, but don't feel comfortable creating one yourself, you can ask for help at Wikipedia:Requested templates.

Guidelines[edit]

Shortcuts:
  • Templates should not be used to store article text. Such content belongs in the article pages themselves.
  • Templates used in articles are designed to provide information to assist readers, such as navigation aids, formatting, or warnings that content is sub-standard. Templates that provide information only of service to editors should not appear on article pages - use the article's talk page or other non-article namespaces.
  • Template function should be clear from the template name, but redirects can be created to assist everyday use of very popular templates.
  • High-risk templates should be semi-protected, template protected, or fully protected as appropriate (see Wikipedia:Protection policy). This applies also to any high-use template redirects.
  • Templates should be clearly documented as to their usage and scope.
  • Templates should not be used to create lists of links to other articles when a category, list page, or "See also" section list can perform the same function.
  • Templates for short, temporary messages that will be removed quickly (such as on User_talk: pages) or that contain text which is not likely to ever be changed should be invoked with substitution (subst:). Typical templates that are intended for long-term use and are likely to require changes should be transcluded for easy future updates.
  • Templates that violate the guidelines on this page, have poorly-defined function, are redundant, become orphaned or used on only one page, or violate other Wikipedia policies may be nominated for deletion at Wikipedia:Templates for discussion.
  • Templates that misrepresent policy or substantially duplicate or hardcode the same functionality of established templates may fit the criteria for speedy deletion.

Suggested practices[edit]

Referencing templates[edit]

Sometimes you will want to refer to a template, rather than actually invoking it. An easy way to do this is to call Template:Tl (short for "template link"). For example, to reference the Cleanup template, typing {{tl|Cleanup}} results in {{Cleanup}}. You can also add parameters using Template:Tlp like {{tlp|Convert|1|m}} which displays as {{Convert|1|m}}.

If you'd like your reference to stand out more, check the template documentation on Template:Tl for other options, such as {{tlb}} (bold), {{tlx}} (code), {{tlxb}} (bold & code), {{tlxi|param1|param2}} (italic parameters), and many more.

Template names[edit]

Template names can be made of one or more words, such as {{Train topics}}. The first character (only) is not case-sensitive, so {{cleanup}} and {{Cleanup}} are the same template, but {{cfd}} and {{cfD}} are not. Template names are easiest to remember if they follow standard English spelling, spacing, and capitalization (also see the naming conventions for articles). Avoid having templates whose names differ only in case, spacing, or punctuation.

Sandbox for experiments[edit]

Main article: Wikipedia:Template sandbox and test cases

If you wish to experiment with templates (and not have your experiments deleted before you are done with them), you may do so in the Template sandbox. You may also use the templates X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, and X12 for experimental purposes. To include a test template, use the form {{X1}} for template X1, {{X2}} for template X2, etc.

Existing templates often each have their own sandbox and test case pages (especially those that use {{Documentation}}). Changes should thoroughly tested there before being applied to the main template, in order to prevent unintentional damage to many pages.

Readability[edit]

For templates that use a large number of parameters, it can be helpful to place each parameter on a separate line and align the equals signs. This help future editors to more easily read the wikicode.

{{Example template name
| first_parameter  = Text of first_value
| second_parameter = Text of second_value
| third_parameter  = Text of third_parameter
| etc              = etc
}}

Line breaks[edit]

Some templates may accidentally cause extra line breaks in the rendered articles. This is especially true of infobox templates and other template boxes that usually float on the right side of an article, since the additional lines will not be seen on the template page. For more information, see Wikipedia:Line-break handling.

As a general guideline, avoid two line breaks together in your template. These may "add up" with other line breaks in the article and be displayed as unwanted white space.

Substitution[edit]

Main article: Wikipedia:Substitution

Invoking a template using the form {{subst:Your message}} will make a copy of the template text and place it on the page, where it will be viewable in the source. The template is no longer transcluded and future changes to the template will not change the text. As a guideline, this method should be used for any short, temporary messages which are removed quickly, such as on User_talk: pages. The standard new user {{Welcome}} message is a good example.

Use subst: also if you need to edit the message after including it on the page. If you don't need to edit it, and would rather the message is automatically updated along with changes made to the template, don't use subst:.

Documentation[edit]

Main article: Wikipedia:Template documentation

Because templates represent a step up in difficulty for the novice editor, documentation should be provided which describes its usage (optional parameters) and scope (where it should be used). There are two different ways to do this:

One alternative is to use <noinclude> to add a minor description direct into the template, for example:

'''This is a {{{1}}} article.'''<noinclude>
Place this template on any article that requires description. It 
takes one parameter, an adjective used to describe the article. 
For example, {{article-describe|bad}} produces the text, 
'''This is a bad article.'''
</noinclude>

Another alternative is to create a formal /doc subpage for the documentation (preferred for templates with multiple parameters, etc.) and add <noinclude>{{Documentation}}</noinclude> below the actual template.

History[edit]

Historically, an "msg:" prefix had to be added in front of the template name when it was used on a page. For example, {{msg:stub}} was typed instead of {{stub}}. This is no longer necessary.

In Wikipedia's first 35 months, there was no template or transclusion mechanism at all. The page Wikipedia:Boilerplate text was created in September 2002 to collect frequently used text in various Wikipedia processes. The MediaWiki namespace was introduced with MediaWiki 1.2.6 on December 6, 2003, and was used not only for the user interface but also for creating boilerplate text messages to be inserted in articles using the {{msg: ...}} syntax. This function was replaced with the Template namespace during the software upgrade to MediaWiki 1.3 on May 30, 2004. As a function of the "Template namespace initialisation script", all non-system messages were moved to the new namespace. The initialisation script also replaced MediaWiki: references in articles with Template: to bypass the redirects created by the moves.

For a short time, Wikipedia:Articles for deletion (then known as votes for deletion or VfD) used MediaWiki: messages named in the format "MediaWiki:VfD-articlename". These were moved to the Template: space in June 2004 and were named "Template:VfD-articlename". This usage is deprecated now in favor of subpages.

Around 2005, growing complexity of template functions and the desire to consolidate similar templates lead to the creation of extremely complex conditional hacks such as nested templates and CSS tricks. These undesirable methods lead to the development of m:Extension:ParserFunctions, added in 2006 with MediaWiki 1.7. By 2009, many problems with template readability and complexity still remained (On templates and programming languages). In 2013, in order to address page load times, mostly due to slow template renders, Lua was enabled, creating a Module: namespace for programmers to make use of (New Lua templates bring faster, more flexible pages to your wiki).

See also[edit]