Wikipedia:Transclusion

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Shortcut:
WP:TRANS

Transclusion is when the contents of one page or document is included within another. In the Wikipedian context, it is the use of the template functionality of MediaWiki to include the same content in multiple documents without having to edit those documents separately.

How transclusion works[change | edit source]

Transclusion-simple.png

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

{{SOMEPAGE}}

Whenever the target page A with this code is rendered, the engine will include in that place not the code itself, but the entire content of the source page B, SOMEPAGE.

Transclusion-multiple-foo.png
Transclusion-multiple-twit.png

This would be a pretty neat trick if it only meant that you didn't have to copy-and-paste from one page to another. For example, you might decide to copy a welcome message to every newcomer's Talk page; you could do this with transclusion (though it might not be the best thing to do!).

But transclusion creates a "live" link between the "template" page and the target page where it appears. When the template is edited, all the other pages change, too.

For example, you might decide to create a (template) page with your mailing address and include that template on not only your page, but all your friends' pages, too. When you move your television and couch to another apartment, you will change your address template, and automatically, that new information will appear on all your friends' pages.

Examples[change | edit source]

This very page uses template transclusion. The section above entitled "How transclusion works" is actually transcluded from the page Wikipedia:Transclusion/How Transclusion Works. This is done using the MediaWiki markup {{Wikipedia:Transclusion/How Transclusion Works}} to include it.

Pages related to MediaWiki transclusion[change | edit source]

Templates[change | edit source]

Related pages[change | edit source]