Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

Jeff Orlof

February 2010

Page templates

Often times, we may have content that we need to include on several pages. For instance, we may want to include a legal disclaimer to certain pages. Or maybe we want to include a header or footer to all pages that fall into a specific category. Basically, if we have content that we want to include on more than one page, we can use a template. Creating a template means we don't have to type the same disclaimer, or header, or footer every time we want to put it onto a page. Instead, we only have to create the template, and include the template tag wherever we want the content to be displayed. If this reason is not enough to make use of templates, consider this—if we want to change some of the content in let's say, the disclaimer, we only need to change the template and all the pages will be updated. If we weren't using a template, we would have to find each page where the disclaimer content was entered and make the necessary changes to keep it consistent. Using templates is just smart management.

Time for action – creating a template

We are going to use the URL method to create a new template. When we do this, we will create an empty page where we can create the template. Once it is saved, it can be added to any page we choose with the template tag {{templatename}}. Of course, the name we save our template as will be substituted for templatename.

For our sample wiki, we will create a template that adds a thank you to the user for supporting free and open source software. A link to both the Free Software Foundation and the Open Source Initiative will be included as well. This template can then be added to the bottom of each page that describes software.

  1. Open your web browser. In the address bar, type . For the example wiki, we will enter you. Hit Enter
  2. .

  3. After you hit the Enter key, you will be taken to the new Template page. Click on edit this page to create and write the content for your template. For the sample wiki, we use:
    Thank you for supporting free and open source software.
    You can learn more about these projects
    from and
  4. Click Show preview to see your new template. If you are satisfied, click Save page.
  5. Open an existing page in your wiki. At the bottom of the page, type {{templatename}} substituting your template for templatename. In the example, we will be opening the page and typing {{Thank you}} at the bottom.
  6. Click on Save page.
Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

What just happened?

While creating a new template, we created a footer that can be added to any page simply by using the template tag in a page. This tag {{templatename}} is what placed the content below the horizontal rule in the previous screenshot. Anytime we include the tag for this template, {{Thank you}}, this piece of content will appear.

Templates with parameters

While the last use of the template tag can really benefit us when we are creating our pages, there is another manner in which we can use templates in our wiki. Do you remember when we created a new namespace called Tutorials? Let's say that we want users to create tutorials for us on our site. Now, if we have 20 different users contributing tutorials, I will bet that there will be 20 different layouts for our tutorial pages. To help keep things more consistent, we can add parameters to our template so that it acts like a subroutine would in a program. Each page where we use this template would have the same parameters; however, the values for each would change. This keeps the pages in the tutorial namespace consistent.

A subroutine is a section of code in a program that executes a task that is one part of the larger program as a whole.

Time for action – using parameters in a template

While this may seem a bit difficult at first, after you complete the exercise you will see how simple it really is. If you have programming experience, the concepts of this should be second nature to you.

In our example, we will make the parameters boldface by enclosing them with '''. However this is not necessary. What is necessary is for us to enclose the value of the parameter in triple brackets {{{ and }}}. For example:


Notice that the parameter is separated from the value by two pipes (||).

  1. Create a new template page using the URL method. For the example wiki, we will create a template called Tutorial by typing
  2. Now, we need to create our template. We use the {| to open the syntax and |} to close it.
  3. Use some of the formatting techniques we have learned. For an example, we will use:
    {|style="width:80%; " border=0"
    | colspan="2" align="center"|'''{{{TutorialName}}}'''

  4. This can serve as a guide for you as well. Simply change the parameters and the values to something that better reflects your wiki.
  5. Make sure the syntax is correct by clicking on Show preview. If everything looks like the following screenshot, you can click Save page. If anything is off, double check your syntax and make the necessary corrections.
    Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

    Now that we have created the template let's put it to use. We will need to pass on values on to our parameters on this page.

  6. Open a new page for editing.
  7. Open the template with double brackets {{. Using the example, we would type {{Tutorial |. Make sure to end this line with a pipe. Hit Enter to drop to the next line.
  8. Now we will pass values on to the parameters. Type your first parameter followed by an equal sign (=) and the value. For example, TutorialName = Installing MediaWiki|. Hit Enter and give your next parameter a value. Continue with this until all parameters have a value.
  9. Close the page with double brackets, }}.
  10. Click Show preview to see if everything is good. If you like what you see, click Save page.
  11. Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

What just happened?

Using the template namespace, we were able to assign parameters to our template. Now, we can apply this template to any page that we want to have a consistent look. Once we declare this template on a new page, we need to pass values on to the parameters. If you don't pass a value to a parameter, it will display the wikitext for the missing parameter. For example, if we fail to include an Introduction using the sample tutorial, the page will display {{{intro}}} where the introduction would be. The pages will now have the same layout, however the content will change. Using this technique, we created a template called Tutorial for the sample wiki and applied it to a new page. We also saw that we can apply many of the formatting techniques we have learned so far to our template to give it a more unique look and to separate items on the page.

Have a go hero

Templates are a great way to give your wiki a consistent look. Go ahead and create some templates that you can apply to pages in your wiki. For starters, create a disclaimer or some other type of footer that you will use on certain pages and apply this template to your wiki. Once you have been able to master this, go ahead and create a template that makes use of parameters unique to your wiki.

If you are interested in learning more about parameters used with templates, search the Internet for Named and Numbered parameters. You can visit the MediaWiki page: that specifically addresses parameter use in a template.

Page redirection

If you have spent any significant time surfing the web, you must have surely come across an instance when you follow a link but are redirected to another page. Generally, this happens for one of the two reasons, either because the content you are looking for has been moved to a different page, or because the page you are on has a similar URL to the page where the content is housed. The latter happens frequently when someone has multiple domains all pointing to one website. For instance, hosts the website but and redirect to so that visitors can view the content.

Both instances would be ideal scenarios where we would redirect a page in our wiki as well. Take for instance our page from the example. Perhaps someone wrote an article on Star Office years ago. When the name was changed to, we could redirect the Star Office page to the newly created page. The second instance from above could be used because generally, people refer to as simply Open Office. We could then create a page called Open Office and redirect it to the page. Both are accomplished by adding the wikitext: #REDIRECT [[Article name]] to the beginning of the edit box. It is important to note that when redirecting an article that contains content, the content does not move to the new page.

You can create a new page with the redirect tag as well.

Time for action – redirecting a page

As we are hoping that many different users contribute to the example wiki, the odds of someone coming along and creating a page named Open Office is likely. As we already have a page named, we would rather add to the existing article than create a new one. Let's go ahead and set up a page redirect to avoid the confusion of two articles on the same topic.

  1. Create a new page. In the example, we will create one called Open Office.
  2. Enter the redirect tag and enclose the page you are redirecting to in double brackets. In the example wiki, we would use:
    #REDIRECT [[]].
  3. Click Save page.
Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

You can see that after you save the page, it creates a nice little redirect message for you and a link to the correct page. If you click on the link, Open Office, in this case, you will be taken to the page. If you enter Open Office in the search box and click Go, you will be taken to the page. but notified that this is a redirect as seen in the following screenshot:

Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

What just happened?

To further organize our wiki, we used a page redirect to send visitors who search for Open Office to the correct page, This can be especially useful when we need to send users from duplicate pages created on our wiki, or if we want to be proactive and create pages with similar names and redirect them to the content filled page. For instance, an internal corporate wiki may have a page titled Human Resources Manual. A proactive administrator may create a page titled HR Manual and redirect it to the Human Resources Manual page.

Editing a redirected page
You can still edit a redirected page by clicking on the text after Redirected from in the previous screenshot. Simply follow the link to the redirect page and click on the edit tab.

Moving a page

If your wiki is as successful as we hope it is, there will come a time when you will need to move a page. Maybe you created a page and then realize that the title is wrong. Or, perhaps, the original article has grown and the current page name no longer seems appropriate for the content. In MediaWiki, we would fix either of these situations by moving the incorrect page to a correct one. Actually, the terms move and rename are used interchangeably in MediaWiki. When you move a page, the history is moved with the content and a redirect is created from the original page to the one you moved to. This is so that any links to the original page will remain intact, simply redirecting the visitor to the page where you moved everything to.

Time for action – moving a page

Moving a page is very easy to do. When we go to a page, we see the move tab. This is what we will use to handle this operation.

Do you remember when we created a page called Top Software by Operating System in our example? Looking over that page, we may decide that a better title for this page would be Top 3 Applications by Operating System. Let's go ahead and move our original page to this new one because it better describes the content.

  1. Open the page that you wish to move. In this exercise, we are opening Top Software by Operating System in the sample wiki. Make sure you are logged in.
  2. Click on the move tab at the top of the wiki.
  3. In the To new title: box, enter the new page name. For our example, we will use Top 3 Applications by Operating System.
  4. You have the option to enter a reason here as well.
  5. Click the Move page button.

After you have completed these steps, you will see something similar to this:

Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

If you need to undo this move, simply move the new page back to the original page. You then have the option of deleting the new page. For example, move Top 3 Applications by Operating System back to Top Software by Operating System and then delete Top 3 Applications by Operating System.

Pages that are in the Image or Category namespace cannot be moved. An image can be uploaded again but a category needs to be manually changed so that all category tags that link to the category have been edited. Protected pages cannot be moved by users, only administrators can move these pages.

What just happened?

In the previous exercise, we learned how to move a page using the move tab on the given page. When we move a page, we are actually renaming the page. When we rename a page using the move tab, we also rename the history page and create a redirect to the new page from the old one.

While we do not discuss subpages in great detail in this article, these pages can also be moved, or renamed, using this technique.

Swapping pages

There may come a time where you need to make some pretty complicated moves. For example, a user creates a page on the example wiki called Installing MediaWiki while another user creates a Tutorial named The Installation of MediaWiki. The title Installing MediaWiki fits the tutorial much better than does The Installation of MediaWiki. We can't rename the tutorial to the better name because it already exists as a page. Sounds like a bit of a dilemma for the administrator right? Lucky for the administrator, he or she can swap pages to fix this little situation.

Time for action – a more creative way to move a page

Swapping pages is nothing more than a bit of creative moving of the pages so you would use the steps laid out in the last exercise here. We will use three different pages here; page 1 is our page titled Installing MediaWiki, page 2 is our page titled The Installation of MediaWiki, and page 3 is our newly-created page which we will call Temp.

  1. Create a new page. This page will be a temporary placeholder so you can name it something like Temp.
  2. Move the first page, in our example this will be Installing MediaWiki, to the Temp page, page 3.
  3. Delete page 1, Installing MediaWiki.
  4. Move page 2, The Installation of MediaWiki and rename it Installing MediaWiki. This is allowed as we deleted the old version of page 1.
  5. Delete page 2.
  6. Move page 3, Temp, to page 2 renaming it The Installation of MediaWiki.
  7. Delete page 3.

When you are done, the tutorial should now be named Installing MediaWiki and the page describing the installation process will be named The Installation of MediaWiki. Temp should be deleted completely.

What just happened?

Being presented with the problem of renaming a page when a page already exists as our desired name, we used a bit of creativity to resolve our issue. Making use of the move feature in MediaWiki, we were able to swap our pages around so that the pages were named according to our wishes. As our wiki grows, we may find that we have to swap pages on a frequent basis as our users may inappropriately name pages or create pages using a name that a different page should actually be using.


As our site grows, we need to be proactive as the wiki administrator and make sure that our content is well organized so that visitors can easily find what they are looking for. In this article, we learned how to organize our content by creating namespaces that allow us to group pages with similar purposes together, and we learned how to use categories to group pages with similar content together. We also looked at creating templates for when we wish to add the same content to a variety of pages, like we would do with a disclaimer. We also took the template feature to another level by adding parameters to it. When we did this, we created a layout so that similar pages can use this template to recreate the layout.

Finally, we learned about redirecting, moving, and swapping pages around so that we can ensure when a visitor comes to our site, they find the information they are looking for because the page titles will match up with page's content.

As we pointed out, our wiki is growing so it is time we focus on what we can do as the administrator of our wiki to not only provide quality content to our visitors, but also make sure that our wiki continues to run smoothly.

You've been reading an excerpt of:

MediaWiki 1.1 Beginner's Guide

Explore Title