Media Wiki Templates

Published on July 11, 2022 at 10:32 pm by LEW


One of the features of media Wiki is the ability to create several types of templates, which can be included within a page to speed the writing process.

The subject of templates can be rather extensive. Therefore I am not going to cover the entire range. Rather I will focus on two basic use cases; Inserting template content at each load, and substituting template content at creation.

I am also assuming you read the previous post in this series.

But before getting into templates, I need to discuss Namespaces in MediaWiki.


In MediaWiki pages are stored in namespace. I have already used some namespace, without really defining what it is. Basically this is a high level way of storing content by purpose. MediaWiki has a number of built in name spaces.

As an example, remember when I created a category. It got prefixed with “Category:”, like the following example.

Category:Retired Techie

We were able to add text to the category page, just like any other page. Prefixing category places a page in the category namespace, where there are specific rules and processes for handling it.

Any page we create without the prefix is included in the main namespace. These will be the majority of pages created in the wiki, the actual articles.

In addition to other namespaces there is also a template namespace, which is what we are interested in for this post. Anything we will be using as a template, we will prefix with “Template:”.

Creating a Template

Lets say we want a specific set of boilerplate included in multiple pages. Could be anything; copyright notice, legal disclaimer, attribution, whatever. As an example I want to include on multiple pages the following text;

© {{CURRENTYEAR}}-{{CURRENTMONTH}}-{{CURRENTDAY2}} by Retired Techie, non commercial attribution


CURRENTYEAR, CURRENTMONTH, CURRENTDAY2 are called magic words. The current date will be substituted in this case. If it was July 5th 2022, we would see 2022-07-05 replace the magic words in the text.

The first step is to create the template page in the Template namespace. This can be done by entering the following into the MediaWiki search bar.

Template:Retired Techie Copyright

I have the option to create and write to the page. I enter my text (above) and save.

Embedded (Transcluded) Templates

I embed a template using the following code in my wiki page.

{{Retired Techie Copy-write}}

This is the normal mode for a template file. Every time I view the page, the template will be dynamically loaded. Any changes I make to the template will be reflected in the next page load.

Substitution Template

Sometimes you do not want a template to be dynamically loaded. You want it to be copied into the page when it is created. For example, I want to create a character form for Maris Stella with headers and key points. Then I want to enter data into the page. I will be modifying the form when fleshing out a character, so I do not want it to reload again. This is called substitution.

If I re-use my example above, instead of embedding, I can substitute with a small change to the code.

{{subst:Retired Techie Copy-write}}

In this case the text will be written into the document, replacing the tag completely. It will no longer dynamically update on reload. You will need to go into the specific page to change it.


In this post we have covered the basics of using templates in your wiki. Obviously there is a lot more to the subject. But the basics given here should get you started.

Add New Comment

Your email address will not be published. Required fields are marked *