Wikipedia:Template substitution: Difference between revisions
→Benefits of substitution: fix typosand clarify wording in the "District of Columbia" example |
m Reverted edits by 200.63.44.29 (talk) to last version by Taylor 49 Tag: Rollback |
||
(27 intermediate revisions by 17 users not shown) | |||
Line 1: | Line 1: | ||
{{guideline| |
{{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, every time you edit a page where |
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 |
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>. |
||
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). |
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 edited or deleted. When |
* 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 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. |
* 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. |
||
* |
* 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. |
* 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 == |
== Drawbacks of substitution == |
||
* 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. |
* 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. |
||
* A substituted template won't be updated when the master template is updated. |
|||
* Substitution increases the size of articles. |
* 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. |
* 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. |
||
Line 23: | Line 22: | ||
== Further reading == |
== Further reading == |
||
[[:en:Wikipedia: |
*[[:en:Wikipedia:substitution|Documentation on English Wikipedia]] |
||
⚫ | |||
[[en:Wikipedia:Template substitution]] |
|||
[[ar:مساعدة:نسخ القوالب]] |
|||
[[da:Hjælp:Skabelonssubstitution]] |
|||
⚫ | |||
[[zh:Wikipedia: |
Latest revision as of 18:46, 1 May 2024
![]() | This page is a guideline on the Simple English Wikipedia. Many editors agree with the ideas on this page. It is a good idea to follow it, but it is not policy. You can change the page as needed, but please use the talk page to make sure that other editors agree with any big changes. |
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.
Usage
[change source]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.