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 refers to the inclusion of the content of one document within another document by reference. In the context of Wikipedia, transclusion involves the MediaWiki software referencing the content of one page, known as the template or source, for inclusion into the content of another page, referred to as the target page. Similar to how any page name can be linked by placing its name in double square brackets, any page name can be transcluded as a template by enclosing it in double curly braces, {{Namespace:Pagename}}
. Any changes made to the template or source are automatically reflected on all pages that include that transcluded content.[a]
If the template's page name does not specify a namespace at the beginning, 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 (:
). For example:
{{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 faithTransclusion and what content it includes or excludes can be controlled using the invisible wikitext tags <noinclude>
, <onlyinclude>
, <includeonly>
, and <section>
on the source page, as further outlined in Markup below.[b] The first three tags enable Partial transclusion, as opposed to the default behavior of double curly braces, which will transclude the entire source page's content. For Selective transclusion, the <includeonly>
or <section>
tags can be used and sections of the source page named, then using parser functions the template can be called with the section name as a parameter: {{#section:Pagename|Sectionname}}
.
Transclusion events occur each time the target page is loaded and the template is rendered. A related event is Substitution, where a template call is replaced with its transcluded source content at the time it is invoked. Unlike transclusion, which continuously updates the target page with changes from the source, substitution results in a one-time inclusion of the content, meaning that subsequent updates to the source content will not be reflected in the target page. For example, a template call for {{Pagename}}
with the subst:
prefix results in the substitution template call {{subst:Pagename}}
. When invoked, this template is replaced, also referred to as substituted, with the actual wikitext of the source page at the time of the call, thereby making it a permanent part of the target page.[c]
Transclusion runs in advance of parsing and can emit syntax fragments to preserve them in the final render. The content being transcluded is processed and embedded before the target page is parsed and fully rendered. When transclusion happens at the HTML layer before parsing, it allows certain content – like syntax fragments such as character entity references like &
and mp;
or specific HTML components – to be inserted in their original form and preserved in the final render. However, this approach may cause pages to render incorrectly or violate the principle of least surprise for the reader.[d] It should be used sparingly when cleaner alternatives are not available. Emitting fragments of template syntax, such as opening braces ({{}}
), is unlikely to re-parse correctly as template syntax in the target page, and it is unwise to rely on such behavior unless formally documented.
It is possible to transclude content from Wikidata into Wikipedia articles or other wikis.
Cite error: There are <ref group=lower-alpha>
tags or {{efn}}
templates on this page, but the references will not show without a {{reflist|group=lower-alpha}}
template or {{notelist}}
template (see the help page).