Knowledgebase
How to manage categories in MediaWiki
Categories in MediaWiki are used to group pages and media files on related subjects. You can create a hierarchical structure of categories and subcategories and assign pages to them. When you add a page to a category this automatically places a link on the page to the category, and it also puts a link to the page on the category page. That category page lists all the pages belonging to it. You can put a page in more than one category.
In this article we'll briefly go over how to add pages to categories and create categories. For screenshots and some more details you can also read the tutorial on how to create and manage categories in MediaWiki.
Category Lists
In addition to using the search function on the site to search for categories, there are also a few special pages that list the categories on your site, both the existing categories and the ones that haven't been created but to which there are links from pages.
For a list of the categories that have items assigned to them (e.g. pages, media, subcategories) go to Tools menu on the left>Special pages button>List of pages section>Categories button. The list includes the existing categories and categories that haven't been created but that have links to them on other pages.
To see a list of the empty categories go to Tools menu>Special pages button>Maintenance reports section>Unused categories button. These are categories which have their own category pages created for them but that have no items assigned to them.
To view the categories that haven't been created but to which there are links on pages go to Tools menu>Special pages button>Maintenance reports section>Wanted categories button.
Add Pages to Categories
Adding a page to a category is quite simple. This is also a way to start with the creation of the category, if that category doesn't exist.
To do this, edit the page and add the following under the main content of the page:
[[Category:Category name]]
Replace Category name with the name of the category, whether an existing one or one that hasn't been created yet. This will automatically put a link on the page to that category. There's an area on the page that's intended for such links to the categories to which the page belongs. It's usually at the bottom of the page, but this depends on the particular skin/theme. A link to the page will also be added on the page of the category itself.
If the category to which you added the page doesn't exist, you should also create a page for that category. Check the next section to learn how to do this.
In case you want to add a link to a category in the content of the page or without assigning the page to the category use the same code but put a colon after the first two brackets: e.g. [[:Category:Category name]].
Create Categories
What you need to do to create a category is to create a page for that category, and this is done in the same way as creating a regular article page. There are a few ways you can do that:
- One way to do this is first to add a page to the category as explained in the previous section. Then use the link that's automatically added on the page. This will open the form for creating the category.
- Another way is to use the search function on the site to search for the name of the category. When you type the name of the category put the Category: namespace in front of it. For example, if you want the category to be named Example Category, search for Category:Example Category. If the category doesn't exist, on the page with the search results there will be a link for creating the category.
- You can also directly open the URL address of the category page that you want to create. For instance, if you want to name it Example Category and the URL of your MediaWiki site is yourdomain.com, then open the URL yourdomain.com/index.php/Category:Example_Category. If the category name has more than one word, put underscores between them in the URL. This will open a page with a link to the form for creating the category.
If you want to create a subcategory of a category, first create it as any other category, then edit it and in the text area for the content of the subcategory add a link to the category to which you want to add it (e.g. [[Category:Category name]]). This will automatically add the subcategory to the category, and it will add a link to the subcategory on the page of the category.