Help:A quick guide to templates

From The Scuba Wiki

Jump to: navigation, search
MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins +/-

This is a quick overview of templates. Full details can be found in Help:Template and Help:Advanced templates.

Templates are pages in the template namespace. This means any page beginning with "Template:", such as [[Template:Templatename]] can be used as a template. The content of a template can be added to a page by typing {{templatename}}.

Templates are used to add recurring messages to pages in a consistent way, to add boilerplate messages, to create navigational boxes and to provide cross-language portability of texts.

Contents

Creating, editing and using templates

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 Template:.

Once you have made the template, you can add {{templatename}} to the pages you want to use it on. Every page using this template will get the same boilerplate text, each time a user visits it. When the template is updated, all pages containing the template tag will be automatically updated.

Alternatively, you can add {{subst:templatename}} to the pages you want to use the boilerplate text on. The system will fetch a one-time copy of the template text and substitute it into the page, in place of the template tag. If anyone edits the template afterwards, pages that used the subst: keyword will not be updated. Sometimes that's what you want.

If the template you want to edit looks like {{foo}}, you would go to Template:foo to edit it. To get there, type in the URL to your address bar, search for it, or make a link in the sandbox and click on it.

Once you are there, just click "edit" or "edit this page" and edit it in the same way you would any other page. You can add anything you would add to a normal page, including text, images and other templates. Please be aware that your edit might affect many pages, so be cautious.

FAQ

Can I use a template in more than one project? 
No, if you want to use it on two different language Wikipedias, for example, you would need to create it twice.
Are templates case sensitive? 
Yes, except usually the first letter.
Can I add parameters? 
Yes, see Help:Template for instructions.
How many templates can I use in a page? 
As many as you like (in older versions you could not use the same one more than 5 times).
I edited the template, so why didn't the page it is used on change? 
There are some caching bugs – solutions include:
Null edit
One way to force refresh is to do a null editedit on the page in which the template appears, and to then click on Save page without having changed anything – there is no need to fill in the Summary field since there will not be any history of this as a change generated.
Reload
Alternatively, refreshing by pressing Ctrl and F5 often helps.
Purge
Another way is purge, by adding "&action=purge" to the address, like you would for "&action=edit" (e.g, :index.php?title=foo&action=purge).
Can I move a template to a new name? 
Yes, this works in exactly the same way as normal 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? 
You can use a template tag within template content, but not within a template tag: in the latter case the parser will prematurely end the original template tag when it reaches the first pair of curly closing braces....
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 Template:.
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 ParserFunctions and see the other "advanced functioning" help pages listed below.

Examples


+/-

Links to other help pages

Help contents
Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary | commons: | mw: | b: | s: | mw:Manual | google
Versions of this help page (for other languages see below)
Meta | Wikinews | Wikipediahttp://en.wikipedia.org/Help:A_quick_guide_to_templates | Wikiquote | Wiktionary
What links here on Meta or from Meta | Wikipedia | MediaWiki
Reading
Go | Search | Stop words | URL | Namespace | Page name | Section
Backlinks | Link | Piped link | Interwiki link | Redirect | Category | Image page
Logging in and preferences
Logging in | Preferences | User style
Editing
Advanced editing | Editing FAQ | Edit toolbar | Export | Import | Shortcuts
Tracking changes
Recent changes (enhanced) | Related changes | Watching pages | Diff
Page history | Edit summary | User contributions | Minor edit | Patrolled edit
Style & formatting
Wikitext examples | Reference card | HTML in wikitext | List | Table | Sorting | Colors
Special input and output
Inputbox | Special characters | Displaying a formula | Images (uploads) | EasyTimeline
Advanced functioning
Template | Advanced templates | Parser function | ParserFunctions | Parameter default
Variable | Magic word | System message | Substitution | Array | Calculation
Page management
Starting a new page | Renaming (moving) a page | Protecting pages | Deleting a page
Special pages
Talk page | Testing | Sandbox | CentralNotice

Template:-

Personal tools
support the site