From Gentoo Wiki
Jump to:navigation Jump to:search

In the context of the Gentoo wiki, transclusion is the use of the template functionality of MediaWiki to include the same content in multiple documents without having to edit those documents separately. Template transclusion is the common way to use template messages, and is implemented by using a template tag, with the form {{template name}}.

It may sometimes be desired to use a template without transcluding it. The automatic one-time copying of a template's code/text to the location of a template tag is called Template substitution or subclusion (substitution + transclusion). To subclude a template's code/text, the template tag is modified from the standard transclusion tag to a substitution tag, simply by adding subst:, creating a tag with the form: {{subst:template name}}.

How transclusion works


To transclude any source page within another target page, include the following code:


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.


For example, a welcome message can be placed on every newcomer's talk page. Transclusion creates a "live" link between the template-page and the target-page(s) upon which the message should appear. When the template is edited, all the target-pages are edited too.

For example, a user can create a (template) page with their mailing address and include that template on not only their page, but all their friends' pages, too. When that user moves their television and couch to another apartment, they will change their address template, and automatically, that new information will appear on all their friends' pages.


Ted Nelson coined the term "transclusion," as well as "hypertext" and "hypermedia", in his 1982 book, Literary Machines.

Partial transclusion

By using "noinclude", "onlyinclude" and "includeonly" markup, it is possible to transclude part of a page rather than all of it. Such partial transclusions can also be achieved by transcluding from other pages such as subpages. It is often useful not to transclude some information, such as template documentation.

For an example of how this technique can be applied to simplify the creation of summary articles, see [1], which consisted of a collection of transcluded lead paragraphs from several main articles.

Transclusion markup

  • <noinclude> - The markup <noinclude> means that the text between the tags will not be transcluded onto another page, but will only appear on the page itself. This is useful for documentation.
  • <includeonly> - The markup <includeonly> means that the text between the tags will only be used when the page is transcluded onto another page, and will not appear on the page itself. This can be useful, for example, for adding categories to pages transcluding a template, without adding the template itself to these categories.
  • <onlyinclude> - The markup <onlyinclude> indicates that only text surrounded by "onlyinclude" markup should be transcluded onto another page. This is the most subtle of the partial transclusion tags because it often overrules the others. If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is only the material within the "onlyinclude" tags which gets transcluded. There can be several such sections, and within each such section, some material might be further excluded by "noinclude" tags, and might also be surrounded by "includeonly" tags so that it does not appear on the original page itself. But material outside the "onlyinclude" tags will be ignored when the page is transcluded onto another page. This can be useful, for example, to repeat a small part of one page on a second one: just surround the small part by onlyinclude tags, and transclude it onto the second page. Note that unlike <noinclude> and <includeonly>, <onlyinclude> will take precedence over enclosing <nowiki> tags. In other words, <code style="white-space:nowrap;"><onlyinclude>My content</onlyinclude></code> produces only "My content" when transcluded.


One can cut and paste the text to be transcluded into a subpage, then use the name of the subpage in the transclusion template. This approach can only be used where subpages are enabled; currently, subpages are enabled in the main, help, user and talk namespaces.

Example: Say the deletion and redirecting of Intel to "xf86-video-intel" needs to be discussed. First, create the subpage "Talk:Intel/delete", write a comment into it, then transclude it in Talk:Intel and "Talk:xf86-video-intel" using the template {{Talk:Intel/delete}}. Comments posted in either talk page will be shown in both.

Special pages

Some pages on Special:Specialpages can be transcluded, e.g. Special:Newpages

Sample: {{Special:Newpages/3}} gives 3 new pages.

Pages related to MediaWiki transclusion


See also