Template writing

From Template Wiki, a repository of MediaWiki templates.
Jump to: navigation, search
Other languages:
English

As templates can often be fairly complex and depend on various external factors, this page outlines some suggestions for writing templates.


Code[edit | edit source]

  • Templates should be self contained and avoid calling other templates (unless absolutely necessary).
  • Templates which include CSS calls in their design should mention so. Generally it's best avoided, unless the CSS classes exist as standard.
  • For icons use vector graphics where possible. A good source for these is Wikimedia Commons' Category:Icons by subject. Miraheze wikis are instant commons enabled, otherwise these images would have to be uploaded locally.


Usage[edit | edit source]

  • Templates should have usage and modification instructions. If they require other templates, this fact should be clearly documented, with links to the required templates.
  • Templates should aim to be easy to read and understand even without usage instructions.


Inputs[edit | edit source]

  • Don't try and make the most extensible template ever - don't make everything a variable for the user to provide. For example, alignment of boxes: just pick an alignment and hard-code it, or make it the default choice.


Layout[edit | edit source]

Using a documentation subpage (Template:templatename/doc) has become standard practice, but is really only better when the documentation is large or has many examples. For smaller, simpler templates with light documentation needs, include the documentation on the template page itself. A /doc subpage for documentation usually implies the need to use the {{Documentation}} template which automatically adds a dependency on another template.

Templates that are not complete should be placed in the :Category:Underconstruction templates via {{Underconstruction}}.


External links[edit | edit source]