Revision as of 10:07, 31 August 2026 by Meryam Sahin (talk | contribs)

Templates provide reusable content that can be embedded in multiple wiki pages. They can contain text, formatting, page structures, or a combination of these. Templates are useful for maintaining consistent content and formatting across pages, such as for infoboxes.
Templates are usually stored in the Template namespace. They can be used locally within a wiki or stored in the Shared resources wiki to make them available across wikis.

Using templates

Templates can provide either reusable content or reusable structures. A template can also combine both.
A template is embedded in a page through transclusion. When a page contains a template, the template content is included when the page is rendered.
Templates can contain:

  • fixed content
  • parameters for variable content
  • formatting
  • conditional logic

Templates are commonly used to maintain a consistent look and feel across multiple pages.

Document control box at the beginning of a document
Document control box created with reusable template content

Create and insert a template

Create a template

Create the template in the Template namespace.
A template can contain fixed content as well as parameters. Parameters allow different values to be supplied when the template is inserted on a page.

Insert a template

A template can be inserted into a page in VisualEditor, as a Content droplet, or directly in wikitext.

In VisualEditor

To insert a template in VisualEditor:

  1. Open the page in VisualEditor.
  2. Select Insert.
  3. Select Template.
  4. Enter the name of the template.
  5. Enter values for the available parameters, if required.
  6. Insert the template.

As a Content droplet

Templates can also be inserted as Content droplets when the template has been configured as a Content droplet by an administrator. Not all templates are available as Content droplets.

  1. Open the page in VisualEditor.
  2. Open the Content droplet menu.
  3. Select the template.
  4. Enter values for the available parameters, if required.

In wikitext

To insert a template in wikitext, enclose the template name in two curly brackets:

 {{NotificationBox}}

When the page is rendered, the template content is included in the page.

Use template parameters

Template parameters allow a template to display different values or content depending on how it is used.
For example, a template can provide parameters for a title, status, or other values that differ between pages. The available parameters depend on the template definition.
When a template is inserted through VisualEditor, available parameters can be entered in the template dialog.

Edit a template

Changes to a template affect all pages that contain the template. Check which pages use a template before modifying it to assess the potential impact of the change.
To find pages that use a template:

  1. Open the template page.
  2. Open More page actions.
  3. Select ...all actions > Links to this page.
  4. Review the listed pages before making changes to a template that is used on multiple pages.

Built-in variables

MediaWiki provides built-in variables that can be used in templates. Built-in variables are not pages in the Template namespace, but they use a similar syntax.
For example:

 {{CURRENTTIME}}

CURRENTTIME returns the current time in UTC.
For more information about built-in variables, see Magic Words.

TemplateData

TemplateData describes the parameters of a template. This information allows the VisualEditor to provide parameter names, descriptions, and other details when a template is inserted or edited.
TemplateData can define information such as:

  • parameter name
  • label
  • description
  • expected value

When TemplateData is available, VisualEditor provides a form for entering the corresponding parameter values. For more information, see TemplateData in the MediaWiki documentation.

Format a template

Template formatting can be defined with CSS.
For styles that are used by multiple templates within the same wiki, add the styles to the wiki's MediaWiki:Common.css page. Each wiki has its own MediaWiki:Common.css. In a Galaxy environment with a main wiki and subwikis, changes to MediaWiki:Common.css in one wiki do not automatically apply to the other wikis.
For styles that apply only to a specific template, use TemplateStyles. TemplateStyles allows CSS to be stored with the template, typically on a subpage of the template.
Storing template-specific styles with TemplateStyles can simplify moving a template and its styles between wikis.

Templates in Shared resources

Templates can be stored in the Shared resources wiki and shared across wikis.
Shared resources is a central wiki for content that is available across multiple wikis. In addition to templates, images and other files can be shared through Shared resources.

View available templates

The available templates can be viewed from the Wiki actions menu.

  1. Open Wiki actions.
  2. In the Overview section, select Templates.

The Templates option opens Special:AllPages with the Template namespace preselected. The page lists the pages currently available in the Template namespace.

Further information

Pages outside the Template namespace can technically be used as templates. However, some template-related functionality requires templates to be located in the Template namespace.
Templates can also be used with the Forms extension.
For information about Page templates, see Page templates.
For information about Shared templates and other content, see Shared resources.
​For more information about templates and their syntax, see Templates in the MediaWiki documentation.