Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Help:Transclusion
Help page
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
<noinclude> {{pp-vandalism|small=yes}} {{Pp-move-indef}} </noinclude> {{redirect|WP:TRANS|text=You may be looking for [[Wikipedia:Transwiki log]], [[Help:Transwiki]], [[Wikipedia:Translation]], [[Wikipedia:WikiProject Transwiki]] or [[Wikipedia:Transgender]]}} {{Broader|Transclusion}} {{Information page|H:TRANS|H:TRANSCL|WP:TRANS|WP:TRANSCL}} '''Transclusion''' means the inclusion of the content of one document within another document by [[Reference (computer science)|reference]]. In Wikipedia transclusion, the [[MediaWiki]] software will refer to the content of one page, the [[wikipedia:WP:template|template]], for inclusion into the content of any other page, the target page. Similar to the way any [[wp:page name|page name]] can become a link by placing its name in double square brackets, any page name can become a template by placing it in double curly braces, '''<syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename}}</syntaxhighlight>'''. Changes made to the template are then automatically reflected on all pages into which that page has been transcluded (though a [[Wikipedia:Purge|purge]] may sometimes be necessary). If the template's [[wikipedia:WP:page name|page name]] does not begin with a namespace, 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 (''':'''). Examples: * '''<syntaxhighlight lang="wikitext" inline>{{Stochastic processes}}</syntaxhighlight>''' will transclude from the page [[:Template:Stochastic processes]] * '''<syntaxhighlight lang="wikitext" inline>{{:Stochastic processes}}</syntaxhighlight>''' will transclude from the page [[Stochastic processes]] (an article, in the Main namespace) * '''<syntaxhighlight lang="wikitext" inline>{{Wikipedia:Assume good faith}}</syntaxhighlight>''' will transclude from the page [[Wikipedia:Assume good faith]] What will transclude from a page can be controlled with the tags <<nowiki/>noinclude>, <<nowiki/>onlyinclude> and <<nowiki/>includeonly> placed in the source page wikitext. (See [[#Markup|markup]], below.) The use of tags enables the template to transclude partially, otherwise the double curly braces will always transclude all content. For ''selective'' transclusion the <<nowiki/>includeonly> parts of the template are named (with the help of [[wp:parser functions|parser functions]]) and that template is then called with the [[Help:Template#Parameters|parameter]] <code>transcludesection=''name''</code>. Transclusion events occur every time the page is ''loaded'', when the template is rendered. Another use of the same mechanism is a one-shot ''[[Help:substitution|substitution]]'' of the template call itself by its transcluded source page. A template call <code>{<nowiki/>{''[[wikipedia:WP:page name#Namespace, pagename, and fullpagename|fullpagename]]''}}</code> with the "subst:" prefix <syntaxhighlight lang="wikitext" inline>{{subst:fullpagename}}</syntaxhighlight> is transcluded once but never again, because the wikitext of that call is replaced (substituted) when its page is ''saved''. What was a one-time template call becomes the actual wikitext of the template at the time of its call. Transclusion runs in advance of parsing the target page at the HTML layer, so it is possible to emit syntax fragmentsβeven fragments of entity references, such as "&a" and "mp;"βthat will parse successfully as combined text in the target page.<!-- tested on an older MediaWiki --> As a design idiom, this tends to violate the principle of least surprise, so it should be used sparingly, when cleaner solution paths do not present themselves. Emitting fragments of template syntax, such as a pair of opening braces, is unlikely to successfully re-parse as template syntax in the target page.<!-- tested on an older MediaWiki --> Even if this worked, it would be unwise to depend upon this as supported behaviour, unless formally documented. Additionally, it is possible to [[Wikipedia:Wikidata#Inserting_Wikidata_values_into_Wikipedia_articles|transclude content from Wikidata]] into other wikis. ==How transclusion works== {{Hatnote|Note: this section is transcluded from [[Help:Transclusion/How Transclusion Works]]}} {{/How Transclusion Works}} ==Transclusion syntax== The general [[Syntax (programming languages)|syntax]] for [[Transclusion|transclusion]] on Wikipedia is <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename}}</syntaxhighlight>, where <code>[[wikipedia:WP:Namespace|Namespace]]:[[wikipedia:WP:Page name|Pagename]]</code> describes the title of a Wikipedia page. Using transclusion syntax requires some knowledge of page titles. On Wikipedia, non-article pages have titles with a visible namespace and pagename separated by a colon; for example, the page [[Wikipedia:Tips]] has <code>Wikipedia</code> as the namespace, and <code>Tips</code> as the pagename. But encyclopedic articles only have a visible pagename in their titles: for example the article [[Potato]] has <code>Potato</code> as the pagename, and the namespace, called [[Wikipedia:What is an article?#Namespace|main namespace]], is not visible. * The [[Help:Wikitext|wikitext]] <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename}}</syntaxhighlight> will transclude the page titled <syntaxhighlight lang="wikitext" inline>Namespace:Pagename</syntaxhighlight>. For example, if a page has the wikitext <syntaxhighlight lang="wikitext" inline>{{Wikipedia:Notability}}</syntaxhighlight> in it, it will transclude the page [[Wikipedia:Notability]] into it. Please note that <syntaxhighlight lang="wikitext" inline>{{WP:Notability}}</syntaxhighlight> would do exactly the same thing, as <code>WP:</code> is a [[Wikipedia:Namespace#Aliases|namespace alias]], which is [[Wikipedia:Shortcut#Namespace_aliases|automatically translated]] by the Wikipedia servers to <code>Wikipedia:</code>. *If the namespace is omitted, but the colon is included, like <syntaxhighlight lang="wikitext" inline>{{:Pagename}}</syntaxhighlight>, the encyclopedic article <code>Pagename</code> will be transcluded. For example, <syntaxhighlight lang="wikitext" inline>{{:Notability}}</syntaxhighlight> will transclude the article [[Notability]]. *If both namepace and colon are omitted, like <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight>, the <code>Template:Pagename</code> will be transcluded. For example <syntaxhighlight lang="wikitext" inline>{{Notability}}</syntaxhighlight>, and also <syntaxhighlight lang="wikitext" inline>{{Template:Notability}}</syntaxhighlight>, will both transclude the [[Template:Notability]]. So, in summary, an example page having the wikitext <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight> or <syntaxhighlight lang="wikitext" inline>{{Template:Pagename}}</syntaxhighlight> included, will transclude the <code>Template:Pagename</code> into that example page. But <syntaxhighlight lang="wikitext" inline>{{:Pagename}}</syntaxhighlight> will have a different effect: it will transclude the article <code>Pagename</code>. Also, <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename}}</syntaxhighlight> will transclude the page <syntaxhighlight lang="wikitext" inline>Namespace:Pagename</syntaxhighlight>, for pages with titles of that format. You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]]. ===Subpages=== [[Wikipedia:Subpages|Subpages]] are pages separated with a "/" (a slash) from their 'parent' page. For a parent page with the name format <code>Namespace:Pagename</code>, its subpage name would have the format <code>Namespace:Pagename/Subpagename</code>. This feature is disabled in the main, file, and MediaWiki [[Wikipedia:Namespace|namespaces]], but not on their corresponding talk namespaces. To transclude a subpage: * The general syntax is <syntaxhighlight lang="wikitext" inline>{{Namespace:Pagename/Subpagename}}</syntaxhighlight>. * On the parent page of a subpage, it is either the general syntax or <syntaxhighlight lang="wikitext" inline>{{/Subpagename}}</syntaxhighlight>. * For a template namespace page, it is either the general syntax or <syntaxhighlight lang="wikitext" inline>{{Pagename/Subpagename}}</syntaxhighlight>. * Article subpages are disabled on this wiki, but would otherwise be <syntaxhighlight lang="wikitext" inline>{{:Pagename/Subpagename}}</syntaxhighlight>. * You also have the option of using [[#Template parameters|template parameters]] and [[#Transclusion modifiers|transclusion modifiers]] For example, to transclude [[Template:Like/doc]], it would be either <syntaxhighlight lang="wikitext" inline>{{Template:Like/doc}}</syntaxhighlight> or <syntaxhighlight lang="wikitext" inline>{{Like/doc}}</syntaxhighlight>. Note that subpage names are case sensitive, and <syntaxhighlight lang="wikitext" inline>{{Like/Doc}}</syntaxhighlight> would not work. ===Template parameters=== {{anchor|Template transclusion}} {{further|Help:Template#Parameters}} {{for|a quick guide to templates|Help:A quick guide to templates}} The most common application of transclusion is the transclusion of [[Help:Template|templates]]. Templates are pages that are written with the prime objective of being included in other pages, either through transclusion or [[wikipedia:Help:Substitution|substitution]]. As shown above, the usual syntax for transcluding a template titled Template:Pagename is <syntaxhighlight lang="wikitext" inline>{{Pagename}}</syntaxhighlight>. However, some templates can also use [[parameter]]s. Parameters are [[Variable (computer science)|variables]] that can be given values (also termed [[Parameter_(computer_programming)#Parameters_and_arguments|arguments]]) that can be passed on to certain templates in order for them to work in different ways. Templates can either use no parameters, a fixed number of parameters, or a variable number of parameters. The number of parameters a template can use is from one upwards. The exact syntax for using parameters with templates can vary greatly, depending on the actual template being used. But, for an example template titled Template:Pagename, which happened to use three parameters, the general form would be: <syntaxhighlight lang="wikitext" inline>{{Pagename|parameter1|parameter2|parameter3}}</syntaxhighlight> {{shortcut|WP:UNNAMED|WP:POSPARAM|WP:POSITIONAL}} with each parameter being substituted with a <code>value</code>, or a <code>parameter name=value</code>, when used in practice. Notice that each parameter is separated with a [[vertical bar]]. Parameters that take the form <code>value</code> are called ''unnamed'' or ''positional parameters.'' Parameters that take the form <code>parameter name=value</code> are called ''named parameters''. With unnamed parameters, the first, second, third etc. parameters are equivalent to parameters '1', '2', '3' etc. in [[Wikipedia:Template_documentation|template documentation.]] Unnamed parameters must be in the correct order, and best placed before named parameters. An example of the syntax using the [[Template:Collapse top]]: <syntaxhighlight lang="wikitext" inline>{{Collapse top|This is the title text|This is a custom warning line|left=true}}</syntaxhighlight> In this particular example, three parameters are used, but Template:Collapse top can actually use a variable number of parameters. <code>This is the title text</code> and <code>This is a custom warning line</code> are the values of unnamed parameters '1' and '2'; and <code>true</code> is the value of the named parameter <code>left</code>. For more details, see [[Help:Template]]. Also, see [[Wikipedia:Template index]] for a list of links to available Main Namespace related templates (usually for encyclopedic articles); and other Namespace related templates (usually for non-article pages); there is also a search function. Template parameters are also used in the [[#Parametrization method|parametrization method]] of selective transclusion. ===Substitution=== [[wikipedia:Help:Substitution|Substitution]] has a similar double curly-bracket syntax, and its action is similar to transclusion. When you preview a page with substitution wikitext in it, its action is identical to transclusion. But when you save a page with substitution wikitext in it, it differs in that it substitutes that wikitext with the actual wikitext of the template. For example, when <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> is saved, it would substitute that wikitext with the actual wikitext from the [[Template:Like]]. In practice, the main difference that this makes is that if an update happened to the wikitext of the Template:Like, it would not update any pages where <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight> had already been saved. ===Magic words=== [[wikipedia:Help:Magic words|Magic words]] are not examples of transclusion. But some have a similar double curly-bracket syntax and action to transclusion. For example, <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME}}</syntaxhighlight> renders the [[Wikipedia:Page name|Fullpagename]] of any Wikipedia page. Like templates, some magic words can also take parameters, which are separated using a colon (:); for example <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME:value}}</syntaxhighlight>. Templates do exist for some magic words, for example [[Template:FULLPAGENAME]]; but these just invoke the related magic word if passing parameters using a vertical bar (|); for example like <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME|value}}</syntaxhighlight>. But magic words parameters are best passed directly by using a colon, for example like <syntaxhighlight lang="wikitext" inline>{{FULLPAGENAME:value}}</syntaxhighlight>, which bypasses any templates. ===Transclusion modifiers=== As discussed above, with the example <syntaxhighlight lang="wikitext" inline>{{subst:Like}}</syntaxhighlight>, the <code>subst:</code> code alters the transclusion to substitution. This is a ''transclusion modifier'', a type of specialist magic word for altering transclusion in some manner. Another example is <syntaxhighlight lang="wikitext" inline>{{:Notability}}</syntaxhighlight>, where the <code>:</code> (colon character) forces transclusion to the main namespace. There are additional transclusion modifiers such as <code>safesubst:</code>, <code>int:</code>, <code>msg:</code>, <code>msgnw:</code>, and <code>raw:</code>. For more details on their usage, see {{slink|mw:wikipedia:Help:Magic words#Transclusion modifiers}}. Also see the modified commands <code>#section:</code>, <code>#section-x:</code> and <code>#section-h:</code> used for [[Help:Labeled section transclusion|labeled section transclusion]]. ==Applications of transclusion== The most common application of transclusion is in the use of [[Help:Template|templates]]. However, other pages are also sometimes transcluded, mainly within project space. ===Composite pages=== Composite pages consist, wholly or partly, of transcluded component pages. The wikitext of such a page may, partly or fully, consist of tags, for the inclusion of component pages. The component pages are usually not in the template namespace, and are often full pages in their own right. Composite pages are intended to gather them into a central location.<!-- "usually not" is too vague; explain the exceptions that prove the rule! --> Examples of composite pages: * [[Wikipedia:Village pump]]: mostly consists of the transcluded page [[Template:Village pump]]. * A daily page like [[Wikipedia:Articles for deletion/Log/2005 May 31]], where each component page consists of the discussion on the deletion of one Wikipedia page, e.g., [[Wikipedia:Articles for deletion/Sp3tt]]. For this day, 75 component pages made up the composite page. * [[m:Meta:Translation/Coordination]], mainly containing ** [[m:Meta:Translation/Coordination/List/Meta]] ** [[m:Meta:Translation/Coordination/List/Main]] This allows the choice between viewing the component pages separately or together. Viewing a composite page is convenient when there are many small, related component pages, in that it allows an overview of all the components without the effort of following numerous links. In general, each component page and the composite page are treated separately. While the actual changes on the component pages will be transcluded onto the composite page, the edit history, recent changes, page-watch settings, page protection, TOC, "what links here" links, and other features of the composite page do not reflect, or affect, the histories, watch settings, protection levels, ''what links here'' lists of the component pages. The composite page is a page in its own right. The talk page of a composite page is used to talk about the composition and the page in general, not the component pages; although it in turn could be a composite of the talk pages of the component pages. Editing a section of a component page can be done directly from the composite page, see [[Help:Section#Editing sections of included templates|editing sections of included templates]]. After saving, one ends up editing the component page to which the section belongs. On projects with the [[Help:Interwiki linking#Interlanguage links|interlanguage link feature]], the composite page shows the combined interlanguage links of all component pages, hence possibly multiple links for one language or even for one page. See also [[Wikipedia talk:Template namespace/Archive 1#transcluding prose]]. ===Pages with a common section=== {{shortcut|WP:COMMONSECTION}} When 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 on other pages. This may also involve creating a third page and transcluding that page onto both pages. This third page may be a page in its own right or a subpage of either of the other two β except in article space, where subpages are not allowed (see [[wikipedia:WP:SUB]]). The third page may be placed in the same namespace as the other pages or in template namespace β again, except for use in article space, where templates should not store article text (see [[wikipedia:WP:TG]]). Common sections like this should be marked with an explanatory header, and/or given a special layout, to inform the reader that this section of the page is in a different location, since transcluding shared article sections can easily confuse novice editors and readers alike if left unmarked. This can be very useful when two [[wikipedia:WP:DAB|disambiguation]] pages share content,{{Disputed inline|talk=Wikipedia talk:Manual of Style/Disambiguation pages#Transclusion|date=September 2017}} or a list page and a disambiguation page share content (see third example below). Examples: *The [[Help:Editing sections of included templates]] article is included in [[Help:Section]] with the markup <syntaxhighlight lang="wikitext" inline>{{Help:Editing sections of included templates}}</syntaxhighlight>. By including a heading in the included article, a user clicking the "Edit" link on that heading in [[Help:Section]] is automatically directed to edit [[Help:Editing sections of included templates]]. *{{pim|Help|Alphabetic order}} * [[Joseph Gordon-Levitt]] transcludes the introduction of [[HitRecord]] into a summary section of the same name, rather than maintaining two copies of the identical text. ===Repetition within a page=== On pages where there is a lot of repetitive information β various kinds of lists, usually β it is sometimes useful to make a template that contains the repeating text, and then call that template multiple times. For example, [[Template:EH listed building row]] is used repeatedly to construct tables in many articles. Simple repetition of the same text can be handled with repetition of a parameter in a single template: e.g., {{tl|3x}}, where <syntaxhighlight lang="wikitext" inline>{{3x| howdy!}}</syntaxhighlight> produces <code>{{3x| howdy!}}</code>. For more information on repetition, see also [[m:Help:Recursive conversion of wikitext]]. For more information on the current template system, see [[Wikipedia:Template namespace]]. <!-- saving a nice programming tutorial on template language 'til someone merges it somehwere Cpiral moved it to [[wp:template namespace#Sandbox_for_experiments]], 9/12/2012 --> ==Partial transclusion== {{shortcut|WP:PARTRANS}} By using {{tag|noinclude|o}}, {{tag|includeonly|o}} and {{tag|onlyinclude|o}} markup, it is possible to transclude ''part'' of a page, rather than all of it. Such partial transclusions can be achieved by transcluding from any pages, including subpages. It is often useful to exclude part of a page in a transclusion, an example being with template documentation. For an example of how this technique can be applied to simplify the creation of [[Wikipedia:Summary style|summary articles]], see how part of the [[History of pathology]] (see the diff [http://en.wikipedia.org/w/index.php?title=History_of_pathology&diff=prev&oldid=207668817 here]) was transcluded into [[Pathology]] (see the diff [http://en.wikipedia.org/w/index.php?title=Pathology&diff=prev&oldid=207669487 here]) using the <syntaxhighlight lang="wikitext" inline>{{:History of pathology}}</syntaxhighlight> markup. The Pathology article at that time (see [https://en.wikipedia.org/w/index.php?title=Pathology&oldid=207669487 here]) mainly consisted of transcluded [[Wikipedia:Manual of Style/Lead section|lead paragraphs]] and other sections from a number of articles. Look at the source to see how this was done. Since then, the Pathology article has been rewritten, and does not include all these transclusions. 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#HitRecord|Joseph Gordon-Levitt]]. {{anchor|Transclusion markup}} <!--Temp anchor until renamed section is checked for link breakage via ''what links here''--> ===Markup=== {{also|Help:Template#Noinclude, includeonly, and onlyinclude|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. But 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 [[wikipedia:WP:preview|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 {{tag|noinclude|o}}, {{tag|includeonly|o}} and {{tag|onlyinclude|o}}. These tags are invisible, but affect both page rendering ''here'' and transclusion rendering ''there''. These tags pair-off to demarcate sections that will create differences. Each tag will describe exceptions to transcluding the whole page named. <pre> <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></pre> {| class="wikitable" style="text-align: center;" ! Wikitext ! What is rendered ''here'' (source page) ! What is transcluded ''there'' (destination page) |- |{{tag|noinclude|content=text1}} text2 |<code>text1 text2</code> |<code>text2</code> |- |{{tag|onlyinclude|content=text1}} text2 |<code>text1 text2</code> |<code>text1</code> |- |{{tag|includeonly|content=text1}} text2 |<code>text2</code> |<code>text1 text2</code> |} An important point to note is that {{tag|noinclude|o}} and {{tag|onlyinclude|o}} do not affect what is page rendered ''here'' at all, unlike {{tag|includeonly|o}}. The {{tag|noinclude|o}} tags stops text inside the tags being transcluded ''there'', while {{tag|onlyinclude|o}} has the opposite effect: it stops text outside of the tags from being transcluded ''there''. Only {{tag|includeonly|o}} stops text from being page rendered ''here''. But naturally enough it is transcluded ''there''. Text outside of the tags will be both rendered ''here'' and transcluded ''there''. 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 {{tag|onlyinclude|o}} section, and then takes a {{tag|noinclude|o}} section out of that; but then picks out yet another {{tag|onlyinclude|o}} section to append to ''there''; but none of this affects their article in any way. Another example is the template programmer, who will {{tag|includeonly|o}} the code section and {{tag|noinclude|o}} the documentation section of a page. ==Selective transclusion== {{shortcut|WP:SELECTIVETRANSCLUSION|WP:SELTRANS}} {{See also|Template:Excerpt|Template:Transcluded section}} ''Selective transclusion'' is the process of [[#Partial transclusion|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 <syntaxhighlight lang="wikitext" inline><onlyinclude> β¦ </onlyinclude></syntaxhighlight> tags, and transcluding the whole page. However, to selectively transclude one section from a template or document into one page, and another section from the same template or document into a second page and/or a different section of the same page, requires a way to: :a) uniquely mark each transcludable section in the source document; and :b) in the target document(s) (those to show the transcluded sections), a way to specify which section is to be transcluded. 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=== Using <syntaxhighlight lang="wikitext" inline>{{#section-h:PAGENAME|SECTIONNAME}}</syntaxhighlight>, one can easily transclude the content within a section on one page to another by referring to the standard, ubiquitous headline-based section headers used throughout Wikipedia. To transclude the lead of an article with this method, one can use {{nowrap|<syntaxhighlight lang="wikitext" inline>{{#section-h:PAGENAME}}</syntaxhighlight>}}. This is simpler than the already widely used selective transclusion methods of the sections below, which require special source document markup. {{High priority|This selective transclusion method often adds a line break above and/or below the section transclusion, depending upon the source and target document markup; to avoid this issue, wrap the selective transclusion template in a {{tlx|trim}} template.}} In other words, use the following modifications to the transclusion code listed immediately above: * Code for transcluding a section in the body of an article: <syntaxhighlight lang="wikitext" inline>{{trim|{{#section-h:PAGENAME|SECTIONNAME}}}}</syntaxhighlight> * Code for transcluding the lead of an article: <syntaxhighlight lang="wikitext" inline>{{trim|{{#section-h:PAGENAME}}}}</syntaxhighlight> <!-- This warrants expansion (better formatting, examples), but I'm creating the section for now - to see what the initial feeback is. -Elvey)--> ====Transcluded section hatnote==== For the purpose of indicating where selectively transcluded article content is located, it is helpful to include a {{tlx|Transcluded section}} hatnote at the top of the corresponding section of the page being transcluded to; i.e., use either {{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME}}</syntaxhighlight>}} or {{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME|part=yes}}</syntaxhighlight>}}, depending upon whether the transcluded content is an entire section of the transcluding page. These templates render as follows: *{{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME#SECTION}}</syntaxhighlight>}} renders as: {{transcluded section|source=PAGENAME#SECTION}} *{{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME#SECTION|part=yes}}</syntaxhighlight>}} renders as: {{transcluded section|source=PAGENAME#SECTION|part=yes}} No such hatnote is needed at the section being transcluded {{em|from}}, since where else the content might appear is not of immediate interest to the reader. However, an HTML comment note between the heading and the transcluded content is probably pertinent so that editors are aware of the repurposing of the material and keep the broader audience in mind with changing the wording. Example: * <syntaxhighlight lang="wikitext" inline><!-- The content of this section is transcluded at PAGENAME2#SECTION and PAGENAME3#SECTION. --></syntaxhighlight> ===Using the labeled section method=== {{main|Help:Labeled section transclusion}} Labeled-section selective transclusion uses the [[wikipedia:WP:PF|parser function]]s listed in [[mw:Extension:Labeled Section Transclusion]], which are enabled on all Wikimedia wikis, to selectively transclude content. See [[Help:Labeled section transclusion]] for how labeled section transclusion works. ===Parametrization method=== =====Source document markup===== Insert 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: :<syntaxhighlight lang="wikitext" inline><onlyinclude>{{#ifeq:{{{transcludesection|SECTIONNAME}}}|SECTIONNAME|</syntaxhighlight> End each such transcludable section with: :<syntaxhighlight lang="wikitext" inline>}}</onlyinclude></syntaxhighlight> =====Target document markup===== To 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: :<syntaxhighlight lang="wikitext" inline>{{PAGENAME|transcludesection=SECTIONNAME}}</syntaxhighlight> Thus each section enclosed within <syntaxhighlight lang="wikitext" inline><onlyinclude> β¦ </onlyinclude> </syntaxhighlight> tags will always be rendered when the <code>transcludesection</code> parameter is not set (when the document is viewed ordinarily, or when the document is transcluded without setting the <code>transcludesection</code> parameter as shown below), and will be rendered by transclusion on any page that does set <code>transcludesection</code> to the section's name. It will ''not'' be rendered by transclusion that uses the <code>transcludesection</code> parameter but sets it to anything other than the name of the section. Also, when providing PAGENAME, without providing a [[Wikipedia:Namespace|Namespace]], the wiki will assume that the PAGENAME belongs in the [[Wikipedia:Template_namespace|Template Namespace]]. To transclude from a [[Wikipedia:Main_namespace|Mainspace]] article, use :PAGENAME. :<syntaxhighlight lang="wikitext" inline>{{:PAGENAME|transcludesection=SECTIONNAME}}</syntaxhighlight> =====Example===== If we want to make the "Principal Criteria" and "Common Name" sections of [[wikipedia:WP:TITLE]] be independently transcludable, we edit the WP:TITLE page and enclose the "Principal Criteria" section as follows: <syntaxhighlight lang="xml+smarty"> <onlyinclude>{{#ifeq:{{{transcludesection|principalcriteria}}}|principalcriteria| ... ''(text of "Principal Criteria" section)'' ... }}</onlyinclude> </syntaxhighlight> Similarly, we enclose the "Common Name" section with: <syntaxhighlight lang="xml+smarty"> <onlyinclude>{{#ifeq:{{{transcludesection|commonname}}}|commonname| ... ''(text of "Common Name" section)'' ... }}</onlyinclude> </syntaxhighlight> Then, to transclude the "Principal Criteria" section into another page, we insert into that page: :<syntaxhighlight lang="wikitext" inline>{{WP:TITLE|transcludesection=principalcriteria}}</syntaxhighlight> To transclude the "Common Name" section into another page, we insert into that page: :<syntaxhighlight lang="wikitext" inline>{{WP:TITLE|transcludesection=commonname}}</syntaxhighlight> 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 <code>transcludesection</code> be given a value that is unique within that page. =====Additional markup for selectively transcluded sub-article leads===== {{further|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: :Replace ::<code>'''{{var|SUB-ARTICLE_PAGENAME}}'''</code> :with ::<syntaxhighlight lang="wikitext" inline><noinclude>'''</noinclude>{{No selflink|{{var|SUB-ARTICLE_PAGENAME}}}}<noinclude>'''</noinclude></syntaxhighlight> 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 {{tlx|no selflink}} template will ensure that it is wikilinked in the sub-article's lead but not in the transclusion to the parent article. In other words: # If the wikilink to the parent article is not a [[wikipedia:WP:Piped link]], replace <code>[[{{var|PARENT_ARTICLE}}]]</code> with {{tnull|no selflink|{{var|PARENT_ARTICLE}}}} in the sub-article's lead # If the [[Wikipedia:Piped link|wikilink to the parent article includes a pipe (e.g., this link)]], replace <code>[[{{var|PARENT_ARTICLE}}|{{var|Piped link wikitext}}]]</code> with {{tnull|No selflink|{{var|PARENT_ARTICLE}}|{{var|Piped link wikitext}}}} in the sub-article's lead ==Drawbacks== {{Shortcut|H:TRANSDRAWBACKS|}} {{see|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, [[Wikipedia:Template limits|template limits]] are imposed by the software to reduce the complexity of pages. Some further drawbacks are listed below. *Transcluded text may have [[Wikipedia:Verifiability|no sources]] for statements that should be [[wikipedia:WP:BURDEN|sourced where they appear]], have different [[wikipedia:WP:CITEVAR|established reference styles]], contain [[Help:Cite errors/Cite error references no text|no-text cite errors]], or [[Help:Cite errors/Cite error references duplicate key|duplicate key errors]]. (To help mitigate these, see [[Help:Cite errors]]) *Excerpts break the link between article code and article output. *Changes made to transcluded content often do not appear in watchlists, resulting in unseen changes on the target page. *Transcluded text may cause [[MOS:REFLINK|repeated links]] or have different [[MOS:ENGVAR|varieties of English]] and [[wikipedia:WP:DATERET|date formats]] than the target page. *Transclusions may not reflect [[Wikipedia:Protection policy|protection levels]], resulting in transcluded text perhaps having a different [[wikipedia:WP:PPLIST|level of protection]] than the target page. See [[wikipedia:WP:CASCADE|Cascading protection]] *{{tl|excerpt}} and related templates may require using {{tag|noinclude|o}}, {{tag|includeonly|o}} and {{tag|onlyinclude|o}} markup at the transcluded page to have [[wikipedia:WP:SELECTIVETRANSCLUSION|selective content]]; that would require monitoring that the markup is sustained. *Excerpts cause editors to monitor transcluded pages for "section heading" changes to ensure transclusion continues to work. (To help mitigate this, see [[MOS:BROKENSECTIONLINKS]]) *Excerpts can result in content discussions [[wikipedia:WP:CROSS-POST|over multiple talk pages]] that may have different considerations or objectives for readers. ==Special pages== {{see also|Wikipedia:Special pages#Miscellaneous}} Some pages on [[Special:Specialpages]] can be transcluded, such as [[Special:AllPages|AllPages]], [[Special:PrefixIndex|PrefixIndex]], [[Special:NewFiles|NewFiles]], [[Special:NewPages|NewPages]], [[Special:RecentChanges|RecentChanges]], [[Special:WhatLinksHere|WhatLinksHere]] (see [[Help:What_links_here#Transclusion_of_WhatLinksHere|help page]]), and [[Special:RecentChangesLinked|RecentChangesLinked]]. Samples: *<syntaxhighlight lang="wikitext" inline>{{Special:AllPages/General}}</syntaxhighlight> β a list of pages starting at "General". *<syntaxhighlight lang="wikitext" inline>{{Special:PrefixIndex/General}}</syntaxhighlight> β a list of pages with prefix "General". *<syntaxhighlight lang="wikitext" inline>{{Special:NewFiles/4}}</syntaxhighlight> β a gallery of the four most recently uploaded files. *<syntaxhighlight lang="wikitext" inline>{{Special:NewPages/5}}</syntaxhighlight> β a list of the five most recently created pages. *<syntaxhighlight lang="wikitext" inline>{{Special:RecentChanges/5}}</syntaxhighlight> β the five most recent changes. *<syntaxhighlight lang="wikitext" inline>{{Special:RecentChangesLinked/General}}</syntaxhighlight> β recent changes to the pages linked from "General". *<syntaxhighlight lang="wikitext" inline>{{Special:Contribs/Larry Sanger|offset=20021108002158|limit=50}}</syntaxhighlight> β user contributions prior to November 2002, limited to 50. Attempting to transclude <syntaxhighlight lang="wikitext" inline>{{Special:Categories}}</syntaxhighlight> will not result in an actual list of categories, but <syntaxhighlight lang="wikitext" inline>{{Special:PrefixIndex/Category:}}</syntaxhighlight> can be used for this purpose. Except for <syntaxhighlight lang="wikitext" inline>Special:RecentChangesLinked</syntaxhighlight>, the slash, and the word or number after the slash, can be omitted, giving a list of pages without a specific starting point, or a list of the default length. [[Help:URL|URL]] parameters can be given like template parameters: *<syntaxhighlight lang="wikitext" inline>{{Special:RecentChanges|namespace=10|limit=5}}</syntaxhighlight> β the five most recent changes in the "Template" namespace. *<syntaxhighlight lang="wikitext" inline>{{Special:PrefixIndex/Jimbo Wales/|namespace=2|stripprefix=1}}</syntaxhighlight> β the subpages for [[User:Jimbo Wales]], but without the user page prefix. ''Note:'' Transcluding certain special pages (such as [[Special:NewPages]]) can change the [[Wikipedia:Page name|displayed title]] of the page. ==See also== ===MediaWiki transclusion=== * [[mw:Transclusion]]: a simple introduction (at MediaWiki). * [[meta:Help:Embed page]]: gives basic information (at Meta-Wiki). * [[Wikipedia:MediaWiki namespace]] ** [[meta:Help:MediaWiki namespace]]: at Meta-Wiki. * [[meta:Help:Variable]]: information on [[MediaWiki]] variables (at Meta-Wiki). * [[Help:Labeled section transclusion]]: ** [[mw:Extension:Labeled Section Transclusion]]: at MediaWiki. ** {{Slink|meta:Help:Template|Labeled section transclusion}}: at Meta-Wiki. ===Templates=== * [[Help:A quick guide to templates]]: a simple introduction. * [[Help:Template]]: more detailed description. ** [[meta:Help:Template]]: help at Meta-Wiki. Links to various other guides in the lead. ** [[mw:Help:Template]]: a simple introduction at MediaWiki. * [[Wikipedia:Template index]]: a directory of available templates. * [[Wikipedia:Template namespace]]: about the template [[wikipedia:WP:Namespace|namespace]]. * [[Wikipedia:Template limits]]: limitations to complexity of pages. ===Other=== {{Wikipedia glossary}} * [[User:Valereee/Substitution and transclusion for dummies|Transclusion for Dummies]] * {{tl|User transclusion}} and {{tl|User transclusion no}} β userboxes for declaring one's stance on transclusion * [[Wikipedia:Purge]]: to force transclusion of newly updated templates. * [[Wikipedia:Substitution]]: the opposite of transclusion. * [[Wikipedia:WikiProject Modular Articles]]: now defunct. * [[MediaZilla:4547|Bugzilla:Request for template transclusion from Commons]]: a proposal for interwiki template support. * [[Mw:User:Peter17/Reasonably efficient interwiki transclusion]] {{Portal templates navbox}} {{Wikipedia technical help|collapsed}} [[Category:Wikipedia editing]] [[Category:Wikipedia page help]] [[Category:Wikipedia template help]]
Summary:
Please note that all contributions to Red Letter Media Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
RLMWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
History of pathology
(
edit
)
Notability
(
edit
)
PAGENAME
(
edit
)
Pagename
(
edit
)
Pagename/Subpagename
(
edit
)
Stochastic processes
(
edit
)
Template:3x
(
edit
)
Template:Absolute page title
(
edit
)
Template:Also
(
edit
)
Template:Anchor
(
edit
)
Template:Broader
(
edit
)
Template:Category handler
(
edit
)
Template:Category link
(
edit
)
Template:Cl
(
edit
)
Template:Collapse top
(
edit
)
Template:Delink
(
edit
)
Template:Disputed inline
(
edit
)
Template:Em
(
edit
)
Template:FULLPAGENAME
(
edit
)
Template:Fix
(
view source
) (protected)
Template:For
(
edit
)
Template:Further
(
edit
)
Template:Hatnote
(
edit
)
Template:High priority
(
edit
)
Template:Hlist/styles.css
(
edit
)
Template:Information page
(
edit
)
Template:Like/Doc
(
edit
)
Template:Like/doc
(
edit
)
Template:Main
(
edit
)
Template:Main other
(
edit
)
Template:Namespace:Pagename
(
edit
)
Template:Namespace:Pagename/Subpagename
(
edit
)
Template:Namespace detect
(
edit
)
Template:Navbox
(
edit
)
Template:No redirect
(
edit
)
Template:No selflink
(
edit
)
Template:Notability
(
edit
)
Template:Nowrap
(
edit
)
Template:Ombox
(
edit
)
Template:PAGENAME
(
edit
)
Template:Pagename
(
edit
)
Template:Pagename/Subpagename
(
edit
)
Template:Pagetype
(
edit
)
Template:Pim
(
edit
)
Template:Plainlist/styles.css
(
edit
)
Template:Portal templates navbox
(
edit
)
Template:Pp-move
(
edit
)
Template:Pp-move-indef
(
edit
)
Template:Pp-vandalism
(
edit
)
Template:Redirect
(
edit
)
Template:Respond
(
edit
)
Template:SHORTDESC:Wikipedia information page
(
edit
)
Template:Section link
(
edit
)
Template:See
(
edit
)
Template:See also
(
edit
)
Template:Short description
(
edit
)
Template:Short description/lowercasecheck
(
edit
)
Template:Shortcut
(
edit
)
Template:Side box
(
edit
)
Template:Slink
(
edit
)
Template:Stochastic processes
(
edit
)
Template:Tag
(
edit
)
Template:Template link
(
edit
)
Template:Template link expanded
(
edit
)
Template:Template link null
(
edit
)
Template:Tl
(
edit
)
Template:Tlx
(
edit
)
Template:Tnull
(
edit
)
Template:Tooltip
(
view source
) (protected)
Template:Tooltip/styles.css
(
edit
)
Template:Transcluded section
(
edit
)
Template:Trim
(
edit
)
Template:Var
(
edit
)
Template:WP:Notability
(
edit
)
Template:WP:TITLE
(
edit
)
Template:Wikipedia glossary
(
edit
)
Template:Wikipedia technical help
(
edit
)
Template:Yesno
(
edit
)
Template:Yesno-no
(
edit
)
Template:Yesno-yes
(
edit
)
Help:Editing sections of included templates
(
edit
)
Help:Transclusion
(
edit
)
Help:Transclusion/How Transclusion Works
(
edit
)
Help:Transclusion/Subpagename
(
edit
)
Module:Anchor
(
edit
)
Module:Arguments
(
edit
)
Module:Broader
(
edit
)
Module:Category handler
(
edit
)
Module:Category handler/blacklist
(
edit
)
Module:Category handler/config
(
edit
)
Module:Category handler/data
(
edit
)
Module:Category handler/shared
(
edit
)
Module:Check for unknown parameters
(
edit
)
Module:Delink
(
edit
)
Module:Effective protection expiry
(
edit
)
Module:Effective protection level
(
edit
)
Module:File link
(
edit
)
Module:For
(
edit
)
Module:Format link
(
edit
)
Module:Hatnote
(
edit
)
Module:Hatnote/styles.css
(
edit
)
Module:Hatnote list
(
edit
)
Module:Labelled list hatnote
(
edit
)
Module:List
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Namespace detect
(
edit
)
Module:Namespace detect/config
(
edit
)
Module:Namespace detect/data
(
edit
)
Module:Navbar
(
edit
)
Module:Navbar/configuration
(
edit
)
Module:Navbar/styles.css
(
edit
)
Module:Navbox
(
edit
)
Module:Navbox/configuration
(
edit
)
Module:Navbox/styles.css
(
edit
)
Module:Pagetype
(
edit
)
Module:Pagetype/config
(
edit
)
Module:Pagetype/rfd
(
edit
)
Module:Pagetype/softredirect
(
edit
)
Module:Protection banner
(
edit
)
Module:Protection banner/config
(
edit
)
Module:Redirect
(
edit
)
Module:Redirect hatnote
(
edit
)
Module:Section link
(
edit
)
Module:Shortcut
(
edit
)
Module:Shortcut/config
(
edit
)
Module:Shortcut/styles.css
(
edit
)
Module:Side box
(
edit
)
Module:Side box/styles.css
(
edit
)
Module:String
(
edit
)
Module:TableTools
(
edit
)
Module:Template link general
(
edit
)
Module:Unsubst
(
edit
)
Module:Wikitext Parsing
(
edit
)
Module:Yesno
(
edit
)
Toggle limited content width