Using Categories

Using MediaWiki Categories
An overview of how categories are used, both on this wiki and in MediaWiki in general.

What are categories used for?
Categorization of articles serves a handful of purposes:


 * Category trees make large numbers of articles more browsable by grouping them hierarchically.
 * The parent category or categories of an article provides one means of finding related articles.
 * The categories an article is in can provide information about the article itself.

For example, the px article is in Category:Perforce and Category:C/C++. Even without knowing anything else about it, these categorizations tell us that this project is a Perforce utility, and that it was written in C or C++. The category links on that page give us an easy means to navigate from that page to other projects that may be similar in either application or implementation.

How do categories work?
Categories in MediaWiki are implemented as a series of links and dynamically generated pages, rather than as a single directory structure, since most wiki articles are created at the top level of the wiki namespace.

A page is added to a category with the same syntax that is usually used to create links to other wiki pages:

Rather than generating a link in the body of the article, a category link generated in this way is placed at the bottom of the page. (Note: a normal link to a category page can be created by placing a : before the word Category.) A page can belong to any number of categories, and typically any page should belong to at least one.

When a page is included in a category, the page representing that category automatically generates a link back to the including page; this automatic reciprocal linking is what makes it possible to navigate a tree of category pages.

If a page is included in a category that does not yet exist, the category link will be in the usual "nonexistent" style (red in most MediaWiki skins). Although the important part of a category page (the links to articles in that category) is generated dynamically, a category page can also be edited like any other wiki page. Text added to a category page is displayed at the top before the dynamically generated listing.

Categories can (and should) themselves be included in other categories; this is done by adding the usual to the category page. Typically each category has at least one parent category, and all articles and categories have a chain of inclusion that goes back to a single top-level category (Category:Contents on this wiki).

Like articles, categories can be members of multiple categories. An example on this wiki is Category:Perforce web APIs, which represents an intersection of two different categories and is therefore a member of both of them.