Help:Templates Overview
From Wikibooks, the open-content textbooks collection
Templates are pages which contain boilerplate text or useful functions intended to be used repeatedly on pages in a consistent way (such as a navigation aid for a book). If you look at Wikibooks' Main page you will see the effect of many templates used together. Templates usually are located within the template namespace on Wikibooks, but almost any namespace can be used. You can add the content of any template to a page by typing {{templatename}} or {{Templatename}} or {{Template:templatename}} (a page entitled Template:Templatename would be used in this example).
Contents |
[edit] How do I use templates?
Templates may be included on pages in the following fashion:
- If you wish to use a template, make sure you know its name.
- Click the edit this page link at the top of the page you wish to add a template to.
- Add the name of the template anywhere in the page by typing the name of the template within sets of double brackets, like so:
{{templatename}}. - Click the save page link at the bottom of the edit screen.
- Your template text will appear.
For example, suppose I wanted to display an explanation of the development stage icons. I would use the format {{stages}}, which would show the following:
[edit] How do I edit a template?
You can type Template:templatename into the search box and press Go or enter on your keyboard. This will display the template. Then click the edit this page link at the top of the page and you can edit the template. Note: This will affect every page which uses the template. You should think carefully before saving your edit.
[edit] How do I create 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 automatically be 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.
[edit] FAQ
- How do I find a suitable template?
- The most frequently used templates are listed on the page Wikibooks:Template messages.
- Are template names case sensitive?
- Yes, except usually the first letter.
- Can I add parameters?
- Yes, see Editing_Wikitext/Templates, Using_Wikibooks/Advanced_Techniques, or Help:Template for instructions.
- I edited the template, so why didn't the page it is used on change?
- There are some caching bugs. One way to force refresh is to do edit 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. Alternatively, refreshing by pressing Ctrl and F5 often helps.
- 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).
- 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.
[edit] See also
- Wikibooks:Template messages for a list of some templates by use
- Help:Templates for a more complete description
- Editing_Wikitext/Templates and Using_Wikibooks/Advanced_Techniques for gentler introductions to templates
- Complete list of templates
- mw:Help:Templates and mw:Help:Extension:ParserFunctions for MediaWiki information about advanced template syntax