Help:Category

Categories are intended to group together pages on similar subjects. Categories are a MediaWiki feature that adds any page with the wikimarkup  in its wikimarkup to the automated listings that are categories. Categories help readers to find, and navigate around, a subject area, to see pages sorted by title, and to thus find article relationships. Categories show how existing 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.

The term category does refer to both the title of a category page—the category pagename—and the category itself. Keeping this in mind while reading about categorization, plus learning a category page layout is a worthwhile investment in research techniques. (See also the search box parameter "incategory".) The layout of a category page is mostly text, but see about ''displaying category trees below.

Summary
The MediaWiki software maintains tables of categories, to which any editable page can be added. To add a page to a category, include " " or " " in that page's wikimarkup. The categories to which a page belongs appear in a box at the bottom of the page.

A category is usually associated with a category page in the "Category:" namespace. 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.

Putting pages in categories
A page belongs to a category if the page's wikimarkup contains a declaration for that category. A category declaration takes the form  or. The declaration must be processed, i.e. it will not work if it appears between

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 TechInfoDepot, see WP:SORTKEY.

Default sort key
It is possible to set a default sort key which is different from  by using the magic word    thus:

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).

Hiding categories
When the magic word  is placed on a category page, that category becomes hidden, meaning that it will not be displayed on the pages belonging to that category. On TechInfoDepot, the magic word is not normally used explicitly, but is applied through the hiddencat template. The feature is mostly used to prevent project maintenance categories from showing up to ordinary readers on article pages.

However, hidden categories are displayed (although listed as hidden):
 * on category pages (whether as parent categories or subcategories);
 * at preview during editing;
 * if the user has selected "Show hidden categories" in user preferences.

Hidden categories are automatically added to Category:Hidden categories.

For guidelines on the hiding of categories on TechInfoDepot, see WP:HIDDENCAT.

Categories and templates
A template can be used to add pages to a category, usually by placing the category link inside   tags on the template (e.g.  ).  When the template is transcluded into the page, the category link becomes active, and the page is added to the category page. This is useful for categories that have high turnover or many pages included, like cleanup categories.

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 <noinclude&gt;...</noinclude&gt; tags.

Parser functions can be used to make the transcluded categories, or the sort key used in them, dependent on other variables, notably PAGENAME.

If the user provides a parameter 'cat=XXX' the page will be categorized at the page  , otherwise it will be categorized at the page   . Calling the template with "cat=" (equal to nothing) disables putting the page in any category.
 * Passing a category by parameter: or

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:XXX.
 * Excluding non-article pages:

On TechInfoDepot it is not recommended that templates be used to populate ordinary content categories of articles. See Categorization using templates in the categorization guideline.

Categorizing redirect pages
Redirect pages can be categorized. The category tag must be placed after the redirect link. On a category page, redirects are listed in italics.

For conventions on the categorization of redirects in TechInfoDepot, see TechInfoDepot:Categorizing redirects.

Moving and redirecting category pages
The only way to move a category page is to manually change all category tags that link to the category, and copy the editable part. There is no automatic way to move a category page in the way one moves an article page. For categories entirely populated through templates (see above) modifying the templates enables all affected articles to be moved to another category, but with the refresh problem mentioned. Almost all category "moves" are made pursuant to a consensus decision at TechInfoDepot:Categories for discussion.

Do not create intercategory redirects. See TechInfoDepot:Categories for discussion for more on category redirects.

Searching for articles in categories
In addition to browsing through hierarchies of categories, it is possible to use the search tool to find specific articles in specific categories. To search for articles in a specific category, type incategory:"CategoryName" in the search box.

An "OR" can be added to join the contents of one category with the contents of another. For example, enter

to return all pages that belong to either (or both) of the categories, as [ here].

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.

"Related Changes" with categories
For a category, the "Related Changes" feature, applied to the corresponding category page, lists recent changes to the pages currently listed as belonging to that category. Where those pages are subcategories or image pages, only changes to their editable parts are listed.

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 watchlists) 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 DynamicPageList (third-party) extension provides a list of last edits to the pages in a category, or optionally, just the list of pages; the simpler DynamicPageList (Wikimedia) is installed on Meta and Wikinews; the extension mw:Extension:DPLforum is installed on Wikia.

Listing all categories
Special:Categories provides an alphabetic list of all categories, with the number of members of each; this number does not include the content of the subcategories, but it includes the subcategories themselves, i.e., each counting as one.

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 Special:AllPages/Category:.

Displaying category trees and page counts
As described at mw:Help:Magic words,  or   returns the number of pages in "Category:Example". Each subcategory counts as one page; pages in subcategories are not counted.

The page Special:CategoryTree 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 CategoryTree extension 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 to display just the subcategory tree, and to display member pages as well.

Dapete's category-visualizer Catgraph will render charts of the tree structure.

You may also use Template:Category tree or Template:Category tree all, instead.

Retrieving category information
Raw information about the members of a category, their sortkeys and timestamps (time when last added to the category) can be obtained from the API, using a query of the form:
 * http ://www.techinfodepot.info/w/api.php?cmtitle=Category:Category_name&action=query&list=categorymembers&cmlimit=500&cmprop=title|sortkey|timestamp

Listings of up to 500 members are possible. If there are more members then the results will include text near the end like this:.

This can be added to the previous one, without quotation marks, for the next page of members:

Category intersection, union, etc.
Various MediaWiki extensions allow intersection of categories, union of categories, display of info about the pages in a category, and more: 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.
 * Semantic MediaWiki
 * Main Page - start page
 * Introduction - allows further intersection with sets of pages defined in terms of relations and attributes
 * Inline queries - provides relation- and attribute-related info about the selected pages and in-page display on any page of categories the same or another page is in*Forum
 * intersection of categories and complements of categories
 * provides the time of last edit for each page
 * Category-/Linkintersection - a toolserver tool to query articles based on boolean expressions of their categories (and, or, not).

See also TechInfoDepot:Category intersection.

For category flattening (displaying the articles in a category's subcategories, sub-subcategories, etc.) see *category flattening with Semantic MediaWiki. See also Category flatten, and Wikimedia bug 1497.