User:Happy-melon/Templates

The MediaWiki software includes the capacity to include the contents of on page in the display of another page - this process is known as transclusion. Since one page can be transcluded on many other pages, the most common use of transclusion is to create boilerplate text, which can be displayed on many pages but updated easily from one location. For this reason, pages which are created primarily for the purpose of being transcluded on other pages are known as templates. Most wikis include a "Template:" help:namespace to house these templates.

This page and its extension Help:Advanced templates form a reference manual for how to use templates and the associated wikimarkup on MediaWiki. Templates can also make use of other features of the MediaWiki software, such as ParserFunctions.

Note: The master version of this page is held at m:Help:Template on Meta-Wiki. All links and template examples work correctly there, but may not if you are viewing a copy of this page on another project.

Introduction
Most MediaWiki sites include a Template namespace which holds pages designed specifically for transclusion on other pages. While this namespace can be renamed, for instance if the project is in a language other than English, the canonical prefix Template: will always function as a shortcut to that namespace. So while the correct name of the Template: namespace on the German Wikipedia is Vorlage:, and so the correct link to the User en Babel box is w:de:Vorlage:User en, using w:de:Template:User en will also work.

A page within the Template: namespace is known as a template, although it is no different to any other page: the same wikimarkup can be used on templates as on any other page. However, many Wikipedias and other MediaWiki sites have policies to restrict the type of content that can appear in the Template: namespace. A page in the template namespace can be linked to like any other page: Template:TEx1 is a link to an example template that will be used later.

This example format will be used throughout this documentation page. If, instead of enclosing the link in square brackets, the link is enclosed in braces  , this is a signal to the MediaWiki parser to transclude the page at that point, rather than link to it. So:

Note that when using braces, the page to be transcluded defaults to the Template: namespace if no other namespace is specified. To transclude a page in another namespace, the full pagename must be specified. So to transclude this page's talk page, type. To transclude a page from the main namespace, use an 'empty' namespace field; to transclude the Main Page, you would need to type. Not all namespaces can necessarily be transcluded: this is a definable parameter of the MediaWiki software which is set in $wgNonincludableNamespaces.

The process of transcluding a template in the manner shown above has several synonyms, including: inclusion and embedding; however inclusion is sometimes used to mean substitution, which is entirely different. The code within the curly braces is often known as a template call.