Help:Transclusion/How Transclusion Works

From Safer nicotine wiki

To transclude any source page (within a single MediaWiki project, such as en:Wikipedia), include the following code in the target page:


Whenever a target page with this code ({{SOURCEPAGE}}) is rendered, the engine will include the entire content of SOURCEPAGE in the target page.

In the example below, let us start with target page A and SOURCEPAGE B.
If B is transcluded in A, then the engine will include in that place not the code ({{B}}) itself but the content of source page B (which consists of only one word, foo).

The top row shows how the target page A renders, while the bottom row shows the code required to transclude the source page within the target page. Note that the position of the code determines how each of the target pages A, P, and Q will render.

The source page content foo will not be highlighted nor boxed on the target page.


A typical use case for transclusion would be if you wanted to place the same welcome message on multiple newcomer talk pages.

Transclusion creates a "live" link between the template page and the target page(s) upon which the template's contents should appear. When the template is edited, the rendering of that template on the target pages is updated as well. Let's say you create a (template) page in Wikipedia with the address of a local Wikimedia event. Next, you transclude that template on your talk page, and also on the talk pages of all local editors to be invited. A week later, the event is moved to a slightly larger place. You would then update the address template, and the revised address will automatically appear on all the other attendees' pages.

Breaking existing transclusions in a template is called breakage. It is to be avoided if possible, as the break will propagate through every target page in which the template (source) page was transcluded.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.