This is an information page. It is not an encyclopedic article, nor one of Wikipedia's policies or guidelines; rather, its purpose is to explain certain aspects of Wikipedia's norms, customs, technicalities, or practices. It may reflect differing levels of consensus and vetting. |
Transclusion means the inclusion of the content of one document within another document by reference. In Wikipedia transclusion, the MediaWiki software will refer to the content of one page, the template, for inclusion into the content of any other page, the target page. Similar to the way any page name can become a link by placing its name in double square brackets, any page name can become a template by placing it in double curly braces, {{Namespace:Pagename}}
. Changes made to the template are then automatically reflected on all pages into which that page has been transcluded (though a purge may sometimes be necessary).
If the template's page name does not begin with a namespace, it is assumed to be in the Template namespace. To refer to a page in the "Main" (article) namespace, it is necessary to prefix it with a colon (:). Examples:
{{Stochastic processes}}
will transclude from the page Template:Stochastic processes{{:Stochastic processes}}
will transclude from the page Stochastic processes (an article, in the Main namespace){{Wikipedia:Assume good faith}}
will transclude from the page Wikipedia:Assume good faithWhat will transclude from a page can be controlled with the tags <noinclude>, <onlyinclude> and <includeonly> placed in the source page wikitext. (See markup, below.) The use of tags enables the template to transclude partially, otherwise the double curly braces will always transclude all content. For selective transclusion the <includeonly> parts of the template are named (with the help of parser functions) and that template is then called with the parameter transcludesection=name
.
Transclusion events occur every time the page is loaded, when the template is rendered. Another use of the same mechanism is a one-shot substitution of the template call itself by its transcluded source page. A template call {{fullpagename}}
with the "subst:" prefix {{subst:fullpagename}}
is transcluded once but never again, because the wikitext of that call is replaced (substituted) when its page is saved. What was a one-time template call becomes the actual wikitext of the template at the time of its call.
Transclusion runs in advance of parsing the target page at the HTML layer, so it is possible to emit syntax fragments—even fragments of entity references, such as "&a" and "mp;"—that will parse successfully as combined text in the target page. As a design idiom, this tends to violate the principle of least surprise, so it should be used sparingly, when cleaner solution paths do not present themselves. Emitting fragments of template syntax, such as a pair of opening braces, is unlikely to successfully re-parse as template syntax in the target page. Even if this worked, it would be unwise to depend upon this as supported behaviour, unless formally documented.
Additionally, it is possible to transclude content from Wikidata into other wikis.