Help:Creating Templates

From UBC Wiki
(Redirected from Help:Create 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

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. Manage template documentation button for TemplateData 2014.png

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:

  1. Click Special Pages > All Pages
  2. 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