Help:Creating Templates
What is a template?
Templates are standard wiki pages whose content is designed to be transcluded (embedded) inside other pages. Templates follow a convention that the name is prefixed with "Template:
", assigning it to that namespace. Therefore you can create them like any other wiki page.
Please feel free to make your own template and contribute! There are many ways to make your own template
- You can import templates from English Wikipedia or MediaWiki! For example, the start tab template was imported from English wikipedia
- If you want to make your own infobox for your course/resource page, you can take a look at the Help:Infobox to learn how to create a documentation.
- You can copy existing templates to create eyour own template
Control template inclusion
You can control content inclusion on the source page by the use of tags, where 'here' is the source page you're editing, and 'there' is where content is being imported to.
- <noinclude> content only here </noinclude>, does not show there
- <includeonly> content does not show here </includeonly>, only there
- <onlyinclude> content will show here and there </onlyinclude> but anything outside of it, will only show here
The obvious application is to add all pages containing a given template to a category, without putting the template itself into that category.
Other possible applications are:
- Categorising templates
- Interlanguage links to similar templates in other languages
- Explanatory text about how to use the template
Templatedata
TemplateData is a way of storing information about a wikitext template and its parameters, so that the visual editor can retrieve and display it in its template editor, thus making it easier to edit pages using that template.
To add a template data, you can do so by editing the template, and clicking on the "Manage templatedata" button.
See https://www.mediawiki.org/wiki/Help:TemplateData for more details.
Organizing templates
For templates to be effective, users need to find them, and find out how to use them.
To find them, users can:
- Click Special Pages > All Pages
- In the Namespace list, choose Template and click Go.
To give usage information, include an example like this one on the template page:
<noinclude> == Usage == Establish a link to a subject: {{NameOfTemplate|Term1+Term2+Term3}} </noinclude>
Then, an editor can simply copy and paste the example to create a similar page.
See Also
- For a list of templates that are used on the UBC Wiki, please see UBC Wiki:Templates
- For more on templates and parameters, please see MediaWiki's Template Help Page or Wikipedia's Template Help Page.