What are MediaWiki Namespaces, Categories, Pages, and Sub-Pages

In this blog you will learn what are namespaces, categories, pages, and subpages in MediaWiki, and how they all interact.

...
WikiTeq
Share:
MediaWiki Namespaces, Categories, Pages and sub-pages

What are Namespaces in MediaWiki?

Namespace are a high-level collection of pages having special purpose and specific behavior. Mediawiki offers separate namespaces for main content, uploaded files descriptions, user pages, system messages, categories, templates, support content (help pages and project pages), system reports and tools. Namespaces can be searched separately, user permissions to access and edit pages can be fine-tuned by namespace. The important idea behind namespaces isto tell the main content from the auxiliary one. For example, if you create manuals for your wiki editors, it would be a good idea to place them into the “Help” namespace, so readers will not find these pages in search results by default. One can easily recognize the namespace of the current page by prefix, eg:

  • Category:Manuals” – page “Manuals” in the Category namespace (includes all available manuals);
  • Help:Manuals” – page “Manuals” in the Help namespace (contains the list of available manuals);
  • Help:How to start a new page” – a single manual page in the Help namespace;
  • Template:Manual” – page “Manual” in the Template namespace (contains structure, layout and other parameters for all manuals);
  • File:Manuals.jpg” – page “Manuals.jpg” in the File namespace (contains a description for the uploaded file with the same name);

Pages with the main content are stored in the unprefixed “Main” namespace:

  • “Manuals” – the article about manuals.

Each namespace – except the “Special” namespace containing system reports and tools – has associated “Talk” namespace allowing to discuss the content of the subject page:

  • Help:How to start a new page” – a subject page;
  • Help_talk:How to start a new page” – a page to discuss the content.

Extensions can define their own namespaces, for example:

  • Widget:Manual” – page “Manual” in the Widget namespace provided by the Widgets extension (in this namespace, unlike in default MediaWiki namespaces, the use of raw HTML, CSS and Javascript is allowed). 

Administrators can configure custom namespaces for the purposes of your particular wiki.


Example of Main namespace article

Example of Main namespace article


Template namespace page

Template namespace page


File namespace page example

File namespace page example


Read more about namespaces here. 

MediaWiki Categories

MediaWiki pages may be assigned to one or several categories, which are collections of related pages. Each category is denoted by a page within the "Category" namespace, listing all pages marked with that specific category name. Since category pages are themselves pages, they can also be categorized, creating a hierarchy. This network of categories, subcategories, and their associated pages can be viewed through a designated page, known as Special:CategoryTree.


MediaWiki Category Page Example

MediaWiki Category Page Example


MediaWiki Category Tree Example

MediaWiki Category Tree Example


Assigning category in VisualEditor

Assigning category in VisualEditor


Read more about categories here. 

MediaWiki Templates

In short, templates are pages for storing reusable content that can be delivered to other pages using the brilliant MediaWiki transclusion technique. The big advantage is that you can customize your template and the changes will be reflected on all pages containing that template. 

Smart templates are the great tool for quick creation of professionally looking pages. The template can be given editor-defined options that can pass variable content while maintaining a consistent look and feel for all elements or pages of which the template is a part.

The values of template parameters can be queried by other extensions (eg. DynamicPageList3) and even stored aside of the page content (eg. Semantic MediaWiki) for the fine-grained grouping or filtering of pages. Other extensions (VisualEditor, PageForms) can provide forms for the guided input of the template values.

MediaWiki infobox example

Mediawiki infobox example

Mediawiki template code example

Mediawiki template code example

 Infobox template input form example

 Infobox template input form example


Read more about templates here.

MediaWiki Subpages

If enabled in the configuration, subpages add some hierarchical organization to wiki pages. Slashes (/) within a page name break the page into parent and subpages, recursively, e.g.:

  • “Main Subject Page” – root page, the parent of all its subpages;
  • “Main Subject Page/subpage” – child page;
  • “Main Subject Page/subpage/sub-subpage” – grandchild page;

This is helpful when there is too much content for one page, or you prefer to add strict structure to your content. Page names in MediaWiki must be unique ( you can read more about MediaWiki Pages here ), but using subpages one can give predictable and not unique names to subpages:

  • “Isaac Newton/Biography
  • “Albert Einstein/Biography

Each subpage provides backlinks to all its ancestors.

MediaWiki navigation by hierarchy example

MediaWiki navigation by hierarchy example


MediaWiki Magic Words

MediaWiki is all about some magic! There are pre-defined switches, variables, and functions, called “magic words,” that can change the default behavior of MediaWiki on a given page, or retrieve technical information about the page or the entire wiki and make it a part of the page content.

When edited with MediaWiki markup, magic words are text strings in a special format, for example:

  • __NOTOC__” - suppresses the automatic creation of the table of contents;
  • {{CURRENTYEAR}}” – displays ... the current year, as you can guess;
  • {{NUMBEROFFILES}}” – shows the number of files uploaded to the wiki from the beginning of time;
  • {{PAGEID}} – retrieves the page identifier from the database;

These are just a few examples and there are many other magic words you can view here.

For those who prefer to edit pages using VisualEditor, many magic words have been made a part of the editor interface.

A table with data about the wiki using code and magic words

A table with data about the wiki using code and magic words


MediaWiki template example rendered

MediaWiki template example rendered


Applying page behavior using VisualEditor interface

Applying page behavior using VisualEditor interface


Read more about magic words here.

Make sure to check out our other MediaWiki blog articles that contain various wiki tutorials and more! If you require any further assistance, have questions, or need MediaWiki support, please do not hesitate to contact us. Our team of experts is eager to provide you with the guidance and expertise you need to make the most out of your MediaWiki installation.

Latest Stories

Here’s what we've been up to recently.


Get our stories delivered

From us to your inbox weekly.