GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing en.wikipedia.org — Help:Transclusion - Wikipedia
"WP:TRANS" redirects here. For other uses, see WP:TRANS (disambiguation).
For encyclopedic coverage of this topic, see Transclusion.
In Wikipedia, transclusion is the inclusion of content from a source page, often a template, into the content of a target page. This happens each time the target page is viewed. Transclusion differs from substitution, which copies the source page into the target page once and permanently. Similarly to creating a wikilink using double square brackets ( If no namespace is specified, 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 (
Transclusion and what content it includes or excludes can be modified by using the invisible wikitext tags 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 in a one-time inclusion of the content. 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 It is possible to transclude content from Wikidata into Wikipedia articles or other wikis. How transclusion worksTo transclude content from a source page within a single MediaWiki project (such as English Wikipedia) onto a target page, use Whenever ExampleConsider an example, complemented by the illustration below, with target pages A, P, and Q, and source page B. If source page B is transcluded into A, the content from B (for instance, the word "foo") will appear in place of the How it worksTransclusion creates a 'live' link between a source page and all target pages where its content is transcluded to and used. Editing the source page automatically updates its content on all target pages that include it. For example, if you create a source page with details about a Wikimedia event and transclude it onto the talk pages of 50 editors you wish to invite, any updates you make to the source page (such as changing the event location) will immediately reflect on all 50 talk pages. Edit source pages with cautionEdits to a source page can impact all target pages using it. If a source page also contains its own transclusions from other source pages, avoid changes that may break these links, as this would affect the source page you are editing and all target pages that transclude it. This is known as 'breakage', and it is best to ensure any updates maintain the integrity of transcluded content across all pages. For example, Main Page is a large page that transcludes its content from multiple embedded source pages such as Wikipedia:Today's featured list. Transclusion syntax
The general syntax for transclusion on Wikipedia follows the format Similar to creating a wikilink using double square brackets ( Wikipedia is structured using namespaces, which organize pages based on their function. For example, a page titled Wikipedia:Tips belongs to the Wikipedia namespace, with When transcluding pages, if no namespace is specified, Wikipedia defaults to the Template namespace. To reference a page in the Article namespace within transclusion syntax, it must be explicitly prefixed with a colon : (e.g., Examples
Additionally, specific § Template parameters and § Transclusion modifiers allow parameters to be passed to templates, alter how transclusion occurs, and therefore the output customized. This is explained in more detail below. SubpagesSubpages, identifiable by a To transclude subpages:
For example, to transclude Template:Like/doc, you could use Template parametersFurther information: Help:Template § Parameters
For a quick guide to templates, see Help:A quick guide to templates.
The most common use of transclusion on Wikipedia is for templates. Templates are specially designed pages intended to be included in other pages using either transclusion or substitution. The standard syntax for transcluding a template titled Template:Pagename is Additionally, many templates support parameters, which are variables that allow templates to function in different ways by passing specific values, also termed arguments. Templates may have no parameters, use a fixed number of parameters, or support a variable number of parameters. The number of parameters a template can accept ranges from one to multiple, depending on its design. The exact syntax for using parameters varies by template. However, for a hypothetical template titled Template:Pagename that accepts three parameters, the general format would be:
Where each parameter in a template can be substituted with either a For example, using the Template:Collapse top with two unnamed parameters and one named parameter:
In this case, For more details, see Help:Template. Additionally, Wikipedia:Template index provides a categorized list of templates, including those for mainspace and other namespaces, along with a search function. Template parameters also play a role in the § Parametrization method of § Selective transclusion, allowing for more dynamic content inclusion. SubstitutionMain page: Help:Substitution
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 in a one-time inclusion of the content. 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 For example, when Magic wordsMain page: Help:Magic words
Magic words are not examples of transclusion. But some have a near identical double curly bracket syntax and similar action to transclusion. For example, Templates do exist for some magic words, for example Template:FULLPAGENAME; but these just invoke the related magic word and pass parameters using the vertical bar ( Transclusion modifiersFurther information: mw:Help:Magic words § Localization int, and mw:Help:Magic words § Transclusion modifiers
A transclusion modifier is a type of specialist magic word for altering transclusion in some manner. An example of which is the UsageTransclusion is commonly used in templates, allowing content to be embedded dynamically across multiple pages. However, it is also applied in other contexts, particularly within project space, where it facilitates the management of structured content. Composite pagesSee also: 2005 Village Pump discussion on transcluding article prose as an unusual issue not covered by policy
Composite pages are created by transcluding multiple component pages, either entirely or in part, into a central page. The wikitext of a composite page may include HTML tags to embed content, typically from standalone pages that are not part of the template namespace. The primary purpose of composite pages is to consolidate related content for easier access. Examples
The use of composite pages allows users to view multiple related pages in one location rather than navigating through individual links. CharacteristicsComposite pages function independently from their component pages in several ways. While changes made to a component page are reflected on the composite page, the composite page maintains its own edit history, recent changes log, page-watch settings, and protection levels, separate from those of its transcluded content. The talk page of a composite page is used specifically for discussions about the composite itself rather than for the individual component pages it includes. However, in some cases, a composite talk page may also transclude discussions from its component pages, allowing for a centralized discussion space. When editing, users can modify sections of a component page directly from the composite page by selecting the edit section links generated by For projects that support interlanguage links, a composite page aggregates all interlanguage links from its component pages. This can sometimes lead to multiple links pointing to the same language or page, reflecting the structure of the transcluded content. Pages with a common sectionWhen two pages need to discuss the same material in the same way, they can share a section. For example, a section of an existing page may be transcluded to other pages. This may also involve creating a third page and transcluding that page onto both pages. This third page may be a standalone page in its own right for another purpose, or a subpage of either of the other two – except in the mainspace, where subpages are not allowed. The third page may be placed in the same namespace as the other pages or in template namespace – again, except for use in mainspace, where templates should not be used to store article text, as this makes it more difficult to edit the content (see Wikipedia:Template namespace). Common sections like this should be marked with an explanatory header, such as using the templates This can be very useful when two disambiguation pages share content, or a list page and a disambiguation page share content (see second example below). Examples:
Repetition within a pageFurther information on repetition, see m:Help:Recursive conversion of wikitext, and on current template system, see Wikipedia:Template namespace
On pages with a lot of repetitive information – typically lists or tables – it can be useful to create a template that contains the repeating text, and then call that template multiple times. For example, {{EH listed building row}} is used repeatedly to build tables in many articles. For simple repetition of the same text, you can use a template like Partial transclusionBy using For an example of how this technique can be applied to simplify the creation of summary articles, see how part of the History of pathology (see the diff here) was transcluded into Pathology (see the diff here) using the Another example can be found in the transclusion of part of HitRecord (introductory paragraph only) into a same-named summary section in Joseph Gordon-Levitt. MarkupSee also: Help:Template § Noinclude, includeonly, and onlyinclude; and Help:Category § Categories and templates
In transclusion, a source page is transcluded into a destination page. But with partial transclusion, only part of that source page will be transcluded into a destination page. In addition, what is transcluded to a destination page does not have to be visible on the source page. Page rendering of a source page can be defined as the rendering of that source page when it is saved, which will be the same as the preview. We can call this rendering here. Transclusion rendering of a source page can be defined as the rendering of a destination page that has a source page transcluded into it; but only that part of the destination page that was transcluded from the source page. The preview of the transclusion rendering will again be identical. We can call this rendering there. There are three pairs of tags involved in cases where page rendering here should differ from transclusion rendering there. As described earlier, these are <noinclude> This section is visible here; but this section is not visible there. Sections outside of these tags will be visible both here and there. </noinclude> <onlyinclude> This section is visible here; this section is also visible there. Sections outside of these tags will be visible here, but will not be visible there. </onlyinclude> <includeonly> This section is not visible here; but it is visible there. Sections outside of these tags will be visible both here and there. </includeonly>
An important point to note is that Only There can be several such sections. Also, they can be nested. All possible differences between here and there are achievable. One example is a content editor who picks an Another example is the template programmer, who will Selective transclusionSee also: Template:Excerpt and Template:Transcluded section
Selective transclusion is the process of partially transcluding one selected section of a document that has more than one transcludable section. As noted above, if only one section of a document is to be transcluded, this can be done by simply surrounding the section of interest with
This section describes how to accomplish this. There are three ways of doing this: (1) Section header-based transclusion, (2) Labeled section transclusion, and (3) the parametrization method. Standard section transclusion
Standard section transclusion uses Standard section transclusion may introduce a leading or trailing line break or newline, depending on the markup in the source and target pages. To prevent this, wrap the transclusion code in a
Hatnote on the target pageTo indicate on the target page where selectively transcluded content originates (its source), a
Hidden comment on the source pageIt is recommended to include a hidden comment at the beginning of the transcluded section in the source page. This comment informs editors that the content is being used elsewhere and serves as a reminder to consider the broader audience when modifying the wording. Additionally, it helps maintain the integrity of the transcluded material on the target page. For example (replace [[PAGENAME#SECTION]] with the name of the target page):
No hatnote should be placed on the source page, in other words no hatnote is needed on the page being transcluded from, as readers do not need to know where else the content appears. Using the labeled section methodMain page: Help:Labeled section transclusion
Labeled-section selective transclusion uses the parser functions listed in mw:Extension:Labeled Section Transclusion, which are enabled on all Wikimedia wikis, to selectively transclude content. See Help:Labeled section transclusion for more details on how labeled section transclusion works. Short instructions:
Parametrization methodSource document markupInsert the following line into the "source" document (the one from which text is to be transcluded), immediately preceding the first line of each section to be transcluded, substituting SECTIONNAME (twice) with the unique name of the respective section. The section name can be any identifier and must be unique within that document:
End each such transcludable section with:
Target document markupTo transclude a section marked as above into another page (the "target page"), use the following line on that page, substituting PAGENAME for the "source" document from which text to be transcluded, and SECTIONNAME with the name of the section you want to transclude:
Thus each section enclosed within Also, when providing PAGENAME, without providing a Namespace, the wiki will assume that the PAGENAME belongs in the Template Namespace. To transclude from a Mainspace article, use :PAGENAME.
ExampleIf we want to make the "Principal Criteria" and "Common Name" sections of WP:TITLE be independently transcludable, we edit the WP:TITLE page and enclose the "Principal Criteria" section as follows: <onlyinclude>{{#ifeq:{{{transcludesection|principalcriteria}}}|principalcriteria| ... ''(text of "Principal Criteria" section)'' ... }}</onlyinclude> Similarly, we enclose the "Common Name" section with: <onlyinclude>{{#ifeq:{{{transcludesection|commonname}}}|commonname| ... ''(text of "Common Name" section)'' ... }}</onlyinclude> Then, to transclude the "Principal Criteria" section into another page, we insert into that page:
To transclude the "Common Name" section into another page, we insert into that page:
Of course, the same page can transclude two or more sections this way by including multiple such lines. There is no limit to how many selectable sections for transclusion a document can have. The only requirement is that each Additional markup for selectively transcluded sub-article leadsFurther information: Wikipedia:Summary style § Using excerpts for article synchronization
Per MOS:LEAD § Format of the first sentence, the first instance of the sub-article title should appear in bold in the first lead sentence of that article; this is often not desirable for a transclusion to a section of the parent article. In addition, the parent article is often wikilinked in the lead of a sub-article; when transcluded to the parent article, this wikilink will appear as bold text. The wikitext markup listed below can be used to address both of these problems. To ensure that the article title is bolded in the first sentence of the sub-article, but unbolded and wikilinked in the transclusion to the parent article, make the following replacement in the sub-article's first lead sentence:
If there is a wikilink to the parent article in the lead section of the sub-article, replacing the wikilink to the parent article with a
DrawbacksFurther information: Wikipedia:Transclusion costs and benefits
Like many software technologies, transclusion comes with a number of drawbacks. The most obvious one being the cost in terms of increased machine resources needed; to mitigate this to some extent, template limits are imposed by the software to reduce the complexity of pages. Some further drawbacks are listed below.
Special pagesSee also: Wikipedia:Special pages § Miscellaneous
Some pages on Special:SpecialPages can be transcluded, such as AllPages, PrefixIndex, NewFiles, NewPages, RecentChanges, WhatLinksHere (see help page), and RecentChangesLinked. Samples:
Attempting to transclude Except for URL parameters can be given like template parameters:
Note: Transcluding certain special pages (such as Special:NewPages) can change the displayed title of the page. Advanced conceptsTransclusion occurs before parsing and can emit syntax fragments, like HTML entities, 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 Emitting fragments of template syntax, such as opening braces ( Notes
See alsoMediaWiki transclusion
Templates
OtherThis page is referenced in the Wikipedia Glossary.
| |||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |