Categories are intended to group together pages on similar subjects. Categories are supported by a MediaWiki feature that enables pages to be added to automated listings. This helps readers to navigate, sort, find related articles and see how information is organised.
Categories are normally found at the bottom of an article page. Clicking the category name brings up a category page listing the articles (or other pages) that have been added to that particular category. There may also be a section listing the subcategories of that category. The subcategorization feature makes it possible to organize categories into tree-like structures to aid navigation.
A category is usually associated with a category page in the "Category:" . A category page contains text that can be edited, like any other page, but when the page is displayed, the last part of what is displayed is an automatically generated list of all pages in that category, in the form of links. Other category pages which appear in this list are treated separately, as subcategories.
A category name can be any string that would be a legitimate . It cannot begin with a lower-case letter. If the category name given in a category declaration begins with a lower-case letter, then it is interpreted as if it were capitalized.
In Wikipedia, it is customary to place category declarations at the end of the wikitext, but before any templates (which themselves transclude categories) and interlanguage links.
When a page has been added to one or more categories, a categories box appears at the bottom of the page (or possibly elsewhere, if a non-default is being used). This box contains a list of the categories the page belongs to, in the order in which the category declarations appear in the processed wikitext. The category names are linked to the corresponding category pages. They appear as redlinks if the corresponding category page does not exist.
Hidden categories are not displayed, except as described below under Hiding categories.
A category page can be edited like any other page. However, when it is displayed, the editable part of the page is followed by automatically generated lists of pages belonging to the category, as follows:
The items in the lists all link to the pages concerned; in the case of the images this applies both to the image itself and to the text below it (the name of the image).
For the way in which the lists are ordered, see Sort order below. The first and second lists are divided into sections, according to the first character of the sort key. These initial characters are displayed above the sections. To suppress these, make all sort keys start with a space.
A category page can only display a limited number of items (currently 200). If more pages belong to the category, there will be a link to the next ones.
The categories box for the category page appears at the bottom, in the same place as for other pages. This contains the categories to which the current category page has been added, i.e. its parent categories (the categories of which it is a subcategory). Add a category page to other categories in the normal way, using the "[[Category:Category name]]" or "[[Category:Category name|Sortkey]]" syntax.
Unlike at and , a space is treated as a space (coming before all other characters), not as an underscore.
Each of the three lists (subcategories, pages, media files) is arranged in the order explained above (except that, in the subcategories list, the namespace indicator "Category:" is not considered). If an item ought to be positioned within a list on the basis of an alternative name (sort key) for that item, then this can be specified in the category tag that places the item in the list:
[[Category:''Category name''|''Sortkey'']]
For example to add an article called Albert Einstein to the category "People" and have the article sorted by "Einstein, Albert", you would type:
Unlike with a piped link (which uses the same syntax), the sort key itself is not displayed to readers. It affects only the order in which pages are listed on the category page.
It is useful to document the system being used for sort keys on the category page. For guidelines about the use of sort keys on Wikipedia, see .
{{DEFAULTSORT:new key}}
In the case of multiple default sort key tags, the last DEFAULTSORT on the final rendering of a page applies for all categories, regardless of the position of the category tags. This also means that a DEFAULTSORT tag included from a template is not effective if another DEFAULTSORT tag occurs later on the page, even if the later DEFAULTSORT tag is also "hidden" (included by another template).
However, hidden categories are displayed (although listed as hidden):
Hidden categories are automatically added to Hidden categories.
For guidelines on the hiding of categories on Wikipedia, see .
Changes to the template, however, may not be reflected immediately on the category page. When you edit an article to add a category tag directly, the list of category members is updated immediately when the page is saved. When a category link is contained in a template, however, this does not happen immediately: instead, whenever a template is edited, all the pages that transclude it are put into the job queue to be recached during periods of low server load. This means that, in busy periods, it may take hours or even days before individual pages are recached and they start to appear in the category list. Performing a null edit to a page will allow it to jump the queue and be immediately recached.
To add the template itself to the category page as well, omit the "includeonly" tags. To add the template to a category without categorizing pages on which the template is transcluded, place the category declaration between
On Wikipedia it is not recommended that templates be used to populate ordinary content categories of articles. See Categorization using templates in the categorization guideline.
For conventions on the categorization of redirects in Wikipedia, see Categorizing redirects.
Do not create intercategory redirects. See Categories for discussion#Redirecting categories for more on category redirects.
An "OR" can be added to join the contents of one category with the contents of another. For example, enter
Note that using search to find categories will not find articles which have been categorized using templates. This feature also doesn't return pages in subcategories.
Notice that "Related Changes" does not list recent changes to pages linked from the editable part of the category page (as it would normally, with a non-category page). (If a workaround is required for this, the links in question could be placed in a template and transcluded onto the category page.)
As usual (unlike with watchlist) recent changes to corresponding talk pages are not shown under "Related Changes". Pages you are watching are bolded on the list (this can be helpful for finding which pages in a given category you have on your watchlist).
"Related Changes" can be used to find pages which have recently been added to a category (unless they were added through modification of a template; then "What links here" should be used with the template). However it is not possible to detect deletions from a category in this way (since once pages have been removed from a category, their edits no longer show up in Related Changes). Another way of finding recent additions is to use an API query; see Retrieving category information below. There is an external tool to watch additions and removals from categories.
The extension provides a list of last edits to the pages in a category, or optionally, just the list of pages; the simpler is installed on Meta and Wikinews; the extension is installed on Wikia, see http://www.wikia.com/wiki/Help:Forums.
The above list contains all categories that have members, regardless of whether they have corresponding category pages. To list all existing category pages (regardless of whether they have members), use .
The page enables you to see the tree structure of a category (its subcategories, their subcategories and so on; the display of files and other member pages is optional).
The can be used to display such a tree on any page. (This is sometimes done on the category page itself, if the category is split over multiple screens, to make all subcategories available on every screen.) The basic syntax is
Dapete's category-visualizer Catgraph will render charts of the tree structure.
You may also use or , instead.
This can be added to the previous one, without quotation marks, for the next page of members: ...&cmcontinue=page|NNNN|TITLE
See also Category intersection.
For category flattening (displaying the articles in a category's subcategories, sub-subcategories, etc.) see * category flattening with Semantic MediaWiki. See also , and Wikimedia bug 1497.
If the user provides a parameter 'cat=XXX' the page will be categorized at the page <includeonly>{{{cat|[[Category:default]]}}}</includeonly>, otherwise it will be categorized at the page [[Category:XXX]]. Calling the template with "cat=" (equal to nothing) disables putting the page in any category.
the variable NAMESPACE is null for mainspace articles. For any space other than mainspace, this ParserFunction will produce an empty string, but for regular articles this will include the article in Category
Categorizing redirect pages
Moving and redirecting category pages
Searching for articles in categories
to return all pages that belong to either (or both) of the categories, as .
"Related Changes" with categories
Listing all categories
Displaying category trees and page counts
to display just the subcategory tree, and
to display member pages as well.
Retrieving category information
Listings of up to 500 members are possible. If there are more members then the results will include text near the end like this:
Category intersection, union, etc.
They all also allow further restriction to a namespace; some allow also restriction to a union of namespaces, or the complement of a union of namespaces. They all allow the info to be displayed in any page, not just a separate category page.
See also