Help:A quick guide to templates: Difference between revisions

Content deleted Content added
No edit summary
Tags: Visual edit Mobile edit Mobile web edit
m Reverted 1 edit by 176.59.22.5 (talk). (Using Twinkle
Line 5:
A '''template''' is a Wikipedia page created to be included in other pages and usually contain repetitive material that might need to show up on any number of articles or pages.
 
Template pages are found in the ¹[[Wikipedia:Template namespace|template namespace]]. This means any page whose title begins with "Template:", such as "[[Template:foo]]", can be used for that purpose. The content from a template titled Template:foo can be added into a Wikipedia page by editing a page and typing <code><nowiki>{{foo}}</nowiki></code> into it. When then viewing the page, <code><nowiki>{{foo}}</nowiki></code> is automatically replaced by the content of the page "Template:foo". If the page "Template:foo" is later altered, all the pages with <code><nowiki>{{foo}}</nowiki></code> in them will change automatically.
 
Among other things, templates are used to add recurring messages to pages in a consistent way, to add [[Wikipedia:Glossary#Boilerplate text|boilerplate]] messages, and to create navigational boxes.
Line 18:
Once you have made the template—for example ''Template:foo''—you can add <code><nowiki>{{</nowiki>''foo''<nowiki>}}</nowiki></code> to the pages that you want to use it on. Every page using this template uses the same [[boilerplate (text)|boilerplate]] text each time that a user visits it. When the template is updated, all pages containing the template tag are automatically updated.
 
Alternatively, if you do not wish the page to reflect future updates to the template, you can add <code><nowiki>{{</nowiki>subst:''foo''<nowiki>}}</nowiki></code> to the pages on which you want to use the boilerplate text. The system fetches a one-time copy of the template text and '''[[Wikipedia:Substitution|substisubstitutes]]''' it into the page in place of the template tag. If anyone edits the template afterwards, pages that used the <code>subst:</code> keyword do '''not update'''. Sometimes that is what you want.
 
'''[[Wikipedia:Substitution|tutes]]''' it into the page in place of the template tag. If anyone edits the template afterwards, pages that used the <code>subst:</code> keyword do '''not update'''. Sometimes that is what you want.
 
If the template that you want to edit looks like <code><nowiki>{{foo}}</nowiki></code>, you would go to Template:foo to edit it. To get there, type "Template:foo" in the search box (see [[Help:Searching|search]]), or make a wikilink like <code><nowiki>[[Template:foo]]</nowiki></code> somewhere, such as in the [[{{ns:4}}:sandbox|sandbox]], and click on it.
Line 27 ⟶ 25:
 
===Parameters===
Templates can have parameters which the page can dynamically incorporate into the transcluded page. Instead of just the template name, like <code><nowiki>{{foo}}</nowiki></code>, an embedded template tag would have additional values separated by [[vertical bar]]s (|), e.g. <code><nowiki>{{foo|July|lc=yes}}</nowiki></code>. Here <code>July</code> is the value of the first unnamed parameter; <code>yes</code> is the value of the named parameter <code>lc</code>. Writing the template page for a template with parameters is more complicated than for a template with no parameters. See [[Help:Template|Help:T emplate]].
 
== Template link template==
Line 41 ⟶ 39:
; Are templates case-sensitive? : Yes, except usually the first letter.
; How can I add parameters? : See [[Help:Template]] for instructions.
; hangeI edited the template, so why didn't the page it is used on change? : Wikipedia and your computer both store webpage ''[[Web cache|caches]]''&nbsp;– or saved copies&nbsp;– and don't always show you an updated page. First, try to [[WP:BYPASS|bypass your browser's cache]] by pressing ⌘R, Ctrl+R, or F5. If that fails, you may need to [[WP:PURGE|purge]] the page's cache (which can be done several different ways). Perhaps the easiest way to do this is by clicking '''edit''' on the page in which the template appears, and then clicking on '''Save page''' without having changed anything&nbsp;– there is no need to fill in the ''Summary'' field since there will not be any ''history'' of this as a change generated.
; I edited the template, so why didn't the page it is used on c
; Can I move a template to a new name? : Yes, this works in exactly the same way as normal [[WikipediaHelp:Moving a page|page moves]]. When a page called for inclusion is a redirect page, the redirect target is included instead.
; hange? : Wikipedia and your computer both store webpage ''[[Web cache|caches]]''&nbsp;– or saved copies&nbsp;– and don't always show you an updated page. First, try to [[WP:BYPASS|bypass your browser's cache]] by pressing ⌘R, Ctrl+R, or F5. If that fails, you may need to [[WP:PURGE|purge]] the page's cache (which can be done several different ways). Perhaps the easiest way to do this is by clicking '''edit''' on the page in which the template appears, and then clicking on '''Save page''' without having changed anything&nbsp;– there is no need to fill in the ''Summary'' field since there will not be any ''history'' of this as a change generated.
; Can I move a template to a new name? : Yes, this works in exactly the same way as normal [[Wikipedia:Moving a page|page moves]]. When a page called for inclusion is a redirect page, the redirect target is included instead.
; Can I use a template within a template? : Yes.
;How do I add a new template?: You start a new template in the same way you would start a normal page. The only difference is that its title must start with {{code|Template:}}. Don't forget to document it so that other editors can use it!
Line 52 ⟶ 49:
<!-- *[[w:en:Template:europe]]: a navigational template -->
*[[w:en:Template:Biological classification]]: a template with parameters (at English Wikipedia).
*[[b:en:Template:GeneralChemTOC|b:en:Template]]:General a horizontal menu bar (at English [[Wikibooks]]).
*[[b:en:Template:GeneralChemTOC|ChemTOC]]: a horizontal menu bar (at English [[Wikibooks]]).
*[[w:en:Template:Underwater work]]: a template as a simple table with a picture (at English Wikipedia).
 
Line 60 ⟶ 56:
*[[m:Help:Templates]] (details from [[Wikimedia]])
*[[m:Help:Advanced templates]] (advanced details from Wikimedia)
*[[Wikipedia:Template namespace]] (the usual [[Wikipedia:Namespace|namenamespace]] for templates)
*[[Wikipedia:Namespace|space]] for templates)
*[[Wikipedia:Transclusion]] (transcluding templates)
*[[Wikipedia:Substitution]] (substituting templates)