(Translated by https://www.hiragana.jp/)
Wikipedia:Template substitution: Difference between revisions - Simple English Wikipedia, the free encyclopedia Jump to content

Wikipedia:Template substitution: Difference between revisions

From Simple English Wikipedia, the free encyclopedia
Content deleted Content added
Huji (talk | changes)
m Reverted edits by 200.63.44.29 (talk) to last version by Taylor 49
Tag: Rollback
 
(29 intermediate revisions by 19 users not shown)
Line 1: Line 1:
{{guideline|[[WP:SUBST]]}}
{{guideline|WP:SUBST}}
The '''subst:''' keyword (short for "substitution") is used as a prefix inside [[Wikipedia:Template|template code]]. It changes the way the software expands the template. Ordinarily, a template will be expanded "on the fly"; that is, the template code calls a separate page for the text every time someone edits a page it's used on. Placing "subst:" inside the curly brackets tells the software to permanently substitute the template with text of the template (that is, the text that is on the template's article page ''when the template is added to the page''). Therefore <nowiki>{{template}}</nowiki> becomes <nowiki>{{subst:template}}</nowiki> and the full text is expanded when you save the page and does not change even if the template is edited.
The "'''subst:'''" keyword (short for "substitution") is used as a prefix inside [[Wikipedia:Template|template code]]. It changes the way the software expands the template. Ordinarily, a template will be expanded "on the fly"; that is, every time you edit a page where the template is used, the template calls a separate page for the text, and the text it shows is updated. Placing "subst:" inside the template code when using it on a page, tells the software to substitute the template with text of the template (that is, the text that is on the template's article page ''when the template is added to the page''), so the output of the template is saved when you save the page, and it does not change even if the template is edited.


== Usage ==
== Usage ==
You can subst a template by adding '''subst:''' to the beginning of the template tag. For example, you can use <nowiki>{{subst:test5}}</nowiki> instead of <nowiki>{{test5}}</nowiki>.
You can subst a template tag by adding "subst:" to a template tag. For example, use <nowiki>{{</nowiki>subst:test5}} instead of <nowiki>{{</nowiki>test5}}. When this is a major component of an edit, it is strongly suggested that the template be mentioned in the [[Wikipedia:Edit summary|edit summary]] (for instance, put "<nowiki>{{subst:test}}</nowiki>" or "test1 applied" in your edit summary so other editors can easily see what you have done). Additionally, when creating or editing templates that are commonly substituted, adding an HTML comment to the template page helps article editors to see how templates are being used (e.g. <code>&lt;!-- Substituted from [[Template:Doctl]] --></code>).

When this is an important part of an edit, it is very good to mention the template in the [[Wikipedia:Edit summary|edit summary]] (for instance, put "<nowiki>{{subst:test}}</nowiki>" or "test1 applied" in your edit summary so other editors can easily see what you have done).


== Benefits of substitution ==
== Benefits of substitution ==
* Templates are often modified or deleted. If a template is boilerplate text, consider whether you want it to vary as the template is improved. If your answer is "no", substitution is warranted. An example of this is the {{tl|welcome}} template. The archives of a user's talk page should show the actual welcome message they received, not the current welcome message.
* Templates are often edited or deleted. When adding a template to a page, ask yourself if you want it to change as the template is edited. If your answer is "no", substitute the template you use.<br />An example of this is the {{tl|welcome}} template. The archives of a user's talk page should show the ''actual'' welcome message they received, not the ''current'' welcome message.
* If there is a template you would like to modify for a single occasion, but you don't want to modify the template for all the pages that use it, and you don't want to make a new template, you can substitute the template and then with a second edit, make the modifications. For example: a template might be used with all the states in the United States and the District of Columbia. The template might be worded correctly for the states, but not for DC. To fix the wording, you can substitute the template and then fix the wording.
* If there is a template you would like to edit for one page, but you don't want to modify the template for all the pages that use it, and you don't want to make a new template, you can substitute the template; then you can make the modifications with a second edit.<br />For example: a template might be used with all the states in the United States and the District of Columbia. For an article about the District of Columbia the template may need to use different words. For this purpose, you can substitute the template and then fix the wording on the article about the District of Columbia.
* Substituting frequently used, but unprotected templates (of which there are few) limits the damage that can be caused by vandalising them. See [[Wikipedia:high-risk templates|high-risk templates]].
* Substitution of frequently-used protected templates can be used to avoid damage caused by template vandalism.
* People can learn more complex wikicode by looking at the output of a substituted template. Using the same template without substitution does not show the template code to them.
* Using certain templates hides wikitext from newcomers, which prevents them from learning how to use it. (Of course, there is a "how to edit" link at the bottom of each edit page.)
* Substituting ''en masse'' '''may''' speed up the site, though the amount and significance of this is the subject of frequent debate. Every time a page is modified, the server must get text from a separate page for every template used. Although each individual template has little effect, the vast number of templates used on Wikipedia is one factor affecting server load and article load times. [[m:Chief Technical Officer|Chief Technical Officer]] [[User:Brion VIBBER|Brion Vibber]] (who "maintain[s] overall responsibility for all technical functions of the Foundation, including both hardware and software") has [http://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28technical%29&diff=36029520&oldid=36025274 said]: "'Policy' shouldn't really concern itself with server load except in the most extreme of cases; keeping things tuned to provide what the user base needs is our job." (See [[Wikipedia:Don't worry about performance]].)
: See [[Wikipedia:Transclusion costs and benefits]] for further details.


== Drawbacks of substitution ==
== Drawbacks of substitution ==
* Once a template is substituted, the result is no longer linked to the template, making it hard to find all pages displaying that text (though categories can sometimes relieve this). This problem can easily be worked around by including a link to the template in the template's code.
* When a template is substituted, the result is no longer linked to the template, so it will be hard to find all pages displaying that text. This problem can be solved by adding a link to the template in the template's code, or by using categories.
* Substitution increases the size of articles.
* A substituted template won't be updated when the master template is updated.
* A substituted template can add a lot of wiki-code or HTML to the article. This way, people who do not have enough skills may find it harder to edit the page.
* If the template is used to standardize the appearance of something, you probably do not want to do a substitution. An example of this is a table of contents or navigation box.
* Substituting templates prevents newcomers from learning to use templates.
* Substituting ''en masse'' — editing thousands of articles with bots — slows down the site and wastes server resources unnecessarily.
* If the template is just being used temporarily, it is usually better not to substitute. Substituted templates are much harder to remove or edit.
* Substitution increases the size of articles in the database and database dumps.
* When a vandalised template is substituted, it is more difficult to repair because it will not fix when the vandalised template is fixed.
* A substituted template can add a lot of wiki-code or HTML to the article, harming accessibility for the less technically inclined.
* Substituting templates prevents newcomers from learning to use templates, and prevents users from finding their documentation.
* If the template is just being used temporarily, it is usually better not to substitute. Substituted templates are much harder to remove or modify.
* When a vandalised template is substituted, it is more difficult to repair than regular vandalism because of the lack of links between the template and its incarnations and the lack of updatability.
* Unsubstituted deletion tags for trivial pages (such as categories and redirects) offer the deleting administrator a convenient, meaningful deletion summary. Example:<br>"''content was: '{&#123;rfd}} #REDIRECT [[Wikipedia]]' (and the only contributor was '[[Special:Contributions/Jimbo Wales|Jimbo Wales]]')''".<br>A precise deletion comment gives onlookers (especially non-administrators unable to view the deleted edits) better insight as to why a specific item may have been deleted. If templates such as {{tl|rfd}}, {{tl|cfr}}, etc. are substituted, the "reason for deletion" field defaults to a blank line. However, pages deleted via {{tl|afd}} and {{tl|mfd}} should be deleted with a link to the subpage where the deletion was discussed.


== Further reading ==
== Further reading ==
[[:en:Wikipedia:Template substitution|Documentation on English Wikipedia]]
*[[:en:Wikipedia:substitution|Documentation on English Wikipedia]]
*[[mw:Help:Substitution]]

[[en:Wikipedia:Template substitution]]
[[ar:مساعدة:نسخ القوالب]]
[[da:Hjælp:Skabelonssubstitution]]
[[sv:Wikipedia:Substitution]]
[[zh:Wikipedia:ばんがえだい]]

Latest revision as of 18:46, 1 May 2024

The "subst:" keyword (short for "substitution") is used as a prefix inside template code. It changes the way the software expands the template. Ordinarily, a template will be expanded "on the fly"; that is, every time you edit a page where the template is used, the template calls a separate page for the text, and the text it shows is updated. Placing "subst:" inside the template code when using it on a page, tells the software to substitute the template with text of the template (that is, the text that is on the template's article page when the template is added to the page), so the output of the template is saved when you save the page, and it does not change even if the template is edited.

You can subst a template by adding subst: to the beginning of the template tag. For example, you can use {{subst:test5}} instead of {{test5}}.

When this is an important part of an edit, it is very good to mention the template in the edit summary (for instance, put "{{subst:test}}" or "test1 applied" in your edit summary so other editors can easily see what you have done).

Benefits of substitution[change source]

  • Templates are often edited or deleted. When adding a template to a page, ask yourself if you want it to change as the template is edited. If your answer is "no", substitute the template you use.
    An example of this is the {{welcome}} template. The archives of a user's talk page should show the actual welcome message they received, not the current welcome message.
  • If there is a template you would like to edit for one page, but you don't want to modify the template for all the pages that use it, and you don't want to make a new template, you can substitute the template; then you can make the modifications with a second edit.
    For example: a template might be used with all the states in the United States and the District of Columbia. For an article about the District of Columbia the template may need to use different words. For this purpose, you can substitute the template and then fix the wording on the article about the District of Columbia.
  • Substitution of frequently-used protected templates can be used to avoid damage caused by template vandalism.
  • People can learn more complex wikicode by looking at the output of a substituted template. Using the same template without substitution does not show the template code to them.

Drawbacks of substitution[change source]

  • When a template is substituted, the result is no longer linked to the template, so it will be hard to find all pages displaying that text. This problem can be solved by adding a link to the template in the template's code, or by using categories.
  • Substitution increases the size of articles.
  • A substituted template can add a lot of wiki-code or HTML to the article. This way, people who do not have enough skills may find it harder to edit the page.
  • Substituting templates prevents newcomers from learning to use templates.
  • If the template is just being used temporarily, it is usually better not to substitute. Substituted templates are much harder to remove or edit.
  • When a vandalised template is substituted, it is more difficult to repair because it will not fix when the vandalised template is fixed.

Further reading[change source]