Wikipedia:Template guidelines

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Wikipedia templates are powerful tools for simplifying many tasks, organizing work, standardizing content, and otherwise improving the encyclopedia. However, they also have potential drawbacks and limitations which should be kept in mind when developing new templates and using existing ones. A number of guidelines have been created to help understand the issues surrounding templates.

Template use[edit]

When possible the 'subst:' instruction should be used to paste the contents of a template into a page. See Wikipedia:Template substitution for a full discussion of this issue.

Template creation[edit]

Before creating a new template you should check Wikipedia:Template messages and appropriate pages linked from it to see if a similar template already exists. Also consider asking on the talk page of a related wikiproject or Wikipedia:Requested templates as other users may know of existing templates or have suggestions on how a new template should be set up.

Also consider that there are some tasks for which templates should generally not be used. See Wikipedia:No disclaimer templates for an example of this.

Template appearance[edit]

Please be careful to make new templates consistent with the layout and appearance of existing templates. See Wikipedia:Template standardisation for guidelines on this topic.

Template design[edit]

There are several issues which should be considered when developing complex templates.

Server load[edit]

When templates are transcluded onto a page the database must be called for the page itself and each included template. This uses more server resources than if the contents of the template were included directly on the page and served from the cache. The significance of this issue is disputed. Lead developer Brion Vibber has said that there's no evidence that this is significantly burdensome at realistic levels for projects on the Wikipedia servers, and shouldn't be worried about on a policy level. [1][2] [3]

Also, when a template is edited all pages which it is transcluded into must be updated. This may lead to a temporary increase in server load, though again the severity of the issue is disputed. In general users should consider the number of pages the template is transcluded into (use the 'What links here' link to get a list) before making updates. If the template appears on thousands of pages extra care should be taken in advance to be certain that the update is correct and complete so that 'downstream' pages will not be broken and any server strain can be minimized. Revert wars should be especially avoided on templates.

See Wikipedia:High-risk templates, Wikipedia:Avoid using meta-templates, and Wikipedia:Transclusion costs and benefits for various discussions of these issues.

Parameters[edit]

Passing parameters to a template can allow one template page to display results which might otherwise require several individual templates. However, each parameter evaluated by the template uses a small amount of server resources. For virtually all templates this is insignificant, but care should be taken to avoid templates growing so complex that they must evaluate one hundred or more parameters.

Conditional Text[edit]

By means of default parameter switches and/or the 'display: none; speak: none;' CSS style settings it is possible to suppress text based on parameters passed to a template. This allows further consolidation of multiple templates into a single template which can perform the same functions. However, see Wikipedia:HiddenStructure for information about accessibility problems with CSS text suppression and Wikipedia:Avoid using meta-templates for concerns about other methods.

More robust conditional logic may be built in to the MediaWiki software to allow this sort of functionality without the limitations noted above.

See also[edit]

Help:Template