Help:A quick guide to templates: Difference between revisions

Content deleted Content added
No edit summary
m Text replacement - "[[Help:Template" to "[[Wikipedia:Help:Template‏‎ "
 
(4 intermediate revisions by the same user not shown)
Line 1:
{{pp-semi-indef|small=yes}}
{{pp-move-indef|small=yes}}
{{Wikipedia how to|H:TQG|sort-by=Templates, A quick guide to}}{{Wiki markup}}
This is a quick '''overview of templates'''. Full details can be found in '''[[Wikipedia:Help:Template|Help:Template]]''' and '''[[metawikimetawikimedia:Help:Advanced templates|Help:Advanced templates]]'''.
 
A '''template''' is a Wikipedia page created to be included in other pages. It usually contains repetitive material that may need to show up on multiple articles or pages, often with customizable input. Most templates are ''scripts'' using [[Wikipedia:MediaWiki|MediaWiki]] parser functions, nicknamed "[[Wikipedia:Help:Magic words|magic words]]", a simple [[Wikipedia:scripting language|scripting language]].
 
Template pages are found in the [[Wikipedia:Template namespace|template namespace]]. This means any page whose title begins with "Template:", such as "[[Wikipedia:Template:foo|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 26:
 
===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 [[Wikipedia:Help:TemplateTemplate‏‎ ]].
 
===Editing existing templates===
Line 51:
 
'''How can I add parameters?'''
: See [[Wikipedia:Help:TemplateTemplate‏‎ ]] for instructions.
 
'''I edited the template, so why didn't the page it is used on change? '''
: Wikipedia and your computer both store webpage ''[[Wikipedia:Web cache|caches]]''&nbsp;– or saved copies&nbsp;– and don't always show you an updated page. First, try to [[Wikipedia:WP:BYPASS|bypass your browser's cache]] by pressing ⌘R, Ctrl+R, or F5. If that fails, you may need to [[Wikipedia: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 '''Publish changes''' 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:Help: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?'''
Line 66:
 
'''Where is the manual for the programming language used to write templates?'''
: The language inside templates is the same language as regular wiki markup, but template writers tend to use the more complex available functions such as #if: statements. See Wikipedia's [[Wikipedia:Help:Template]] and Wikimedia's [[mwmediawikiwiki:Help:Template|Help:Template]], including all of "advanced functioning" help pages listed toward the bottom of [[mwmediawikiwiki:Help:Template#Links to other help pages|that page]].
 
==Examples See Also ==
For more detail see wikipedia page [[wikipedia:Help:A quick guide to templates]]
*[[w:en:Template:stub]]: an often used message (at English Wikipedia).
<!-- *[[w:en:Template:europe]]: a navigational template -->
*[[w:en:Template:Biological classification]]: a template with parameters (at English Wikipedia).
*[[b:en:Template:GeneralChemTOC]]: a horizontal menu bar (at English [[Wikibooks]]).
*[[w:en:Template:Underwater work]]: a template as a simple table with a picture (at English Wikipedia).
 
== Wikipedia-specific help ==
*[[Help:Template]] (more details)
*[[m:Help:Templates]] (details from [[Wikimedia]])
*[[m:Help:Advanced templates]] (advanced details from Wikimedia)
*[[Wikipedia:Template namespace]] (the usual [[Wikipedia:Namespace|namespace]] for templates)
*[[Wikipedia:Transclusion]] (transcluding templates)
*[[Wikipedia:Substitution]] (substituting templates)
*[[Wikipedia:Template messages]] (categorised list of links to available templates)
 
{{Help navigation}}
{{Wikipedia technical help|collapsed}}