Help:Category: Difference between revisions

From JonnyBWiki
Jump to navigation Jump to search
mNo edit summary
 
No edit summary
Line 1: Line 1:
A '''category''' is a software feature of MediaWiki. To avoid confusion with the general term ''category'', it may sometimes be useful to use the term ''MediaWiki category''.
<languages/>
{{TNT|PD Help Page}}
<translate>
<!--T:1-->
Categories, a software feature of MediaWiki, provide automatic indexes that are useful as tables of contents.


Categories provide automatic indexes, that are useful as table of contents. Together with [[link]]s and [[templates]] they structure a project.
<!--T:2-->
You can categorize pages and files by adding one or more '''Category''' {{#ifeq:Category|{{ns:category}}||'''({{ns:category}})'''}} tags to the content text. These tags create links at the bottom of the page that take you to the list of all pages in that category, which makes it easy to browse related articles.


''Note:'' Categories work only in MediaWiki version 1.3 and later.
== Summary == <!--T:3-->


==Putting an item in a category==
<!--T:4-->
A page in any namespace can be put in a category by adding a category tag, e.g.:
Each of the pages in the '''Category''' [[Help:Namespace|namespace]] represents a so-called '''category''', a grouping of related pages, and contains an index for the pages of its category. For example, this page belongs to "[[:Category:Help]]". If you open the "[[:Category:Help]]" page, you will see a link to this page there.


<nowiki>[[</nowiki>Category:''Category name'']]
<!--T:5-->
When a page belongs to one or more categories, these categories appear at the bottom of the page (or in the upper-right corner, depending on the [[Help:Preferences|skin]] being used).


This provides a link to the appropriate category page, which is in the namespace "Category". A category typically has an editable part, containing at least a category tag of a supercategory, see below; if it does not, the link to the category page is treated as a link to a non-existing page, hence it is a link to the edit page.
<!--T:6-->
The category pages themselves contain 2 parts:


Pages can be included in more than one category by adding multiple category tags. These links do not show up in-page, but at the page margin in a fixed place, depending on the skin (the bottom for Monobook, the upper right corner for Standard). Category tags may be placed anywhere in the article, although they are typically added to the end of the article to avoid undesirable text display side effects. Category links are displayed in the order they occur in the article, unlike the automatic ordering of lists in the category pages themselves (see below).
<!--T:7-->
* at their beginning, an optional part may contain text that can be edited, like any other page,
* at their end, an ever present, automatically generated, alphabetical list of all pages in that category, in the form of links. (In fact, in ASCII order. See [[Help:Special page]]).


Putting an image in a category is equivalent with putting the image page in it.
<!--T:8-->
To assign a category to a page, simply add the link "<nowiki>[[</nowiki>Category:''Category name'']]" to the page's wikitext. The usual place to add it is at the bottom of the page.


== Subcategories ==
<!--T:9-->
To link a category page within a page as a normal wiki link (without adding the page to the category), prefix the link name with a colon.  For example: <nowiki>[[</nowiki>:Category:Not in this category]]


Adding a category tag to a category page makes the edited category a subcategory of the tag's category.
<!--T:10-->
New categories can be [[Help:Starting a new page|created]] before assigning any page to it, in the same way as any other regular page.


For example, you could edit <nowiki>[[Category:Soccer]]</nowiki> and add the link <nowiki>[[Category:Sports]]</nowiki>. The Soccer category would then be a subcategory of the Sports category.
<!--T:11-->
Individual wikis may have their own top-level categories, such as [[wikipedia:Category:Contents|Category:Contents]] in Wikipedia.


==Category page==
<!--T:12-->
A category page consists of:
For a complete list of all categories which have at least one page, see [[Special:Categories]].
*editable text
*list of subcategories; how many there are is also displayed; if there are no subcategories the header and count are not shown.
*list of pages in the category, excluding subcategories and images; the number of items in this list is called the number of articles; if there are none the header is shown anyway, and "There are 0 articles in this category." {{new|the namespace prefix is no longer shown.}}
*list of images with thumbnails (how many there are is not counted); the first 20 characters of the image name are shown, with dots if that is not the full name; also the file size is shown. As opposed to the second and third section, this section does not have subheaders per letter, it has not even a header itself and visually seems to fall under the header of the previous section "Articles in category ...", even though in counting the articles, images/image pages are not considered articles).


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).
<!--T:13-->
For a complete list of all created/edited categories, including the ones that don't have any pages, see [[Special:Allpages/Category:]] (note the colon at the end).


The first and second list each have a header for each first character, dispensed with if there are no entries for a header.
==Adding a page to a category== <!--T:14-->


On Meta and Wikipedia a redirect to a category shows the editable text only. To get the full page after being redirected, use the link "Image", or "Category", respectively.
<!--T:15-->
To add a page or uploaded file to a category, simply edit the page and add the following text (where '''''Name''''' is the name of the category you want to add it to).
</translate>


On Commons a redirect to a category gives the full page, but not the subcategories and pages in the redirect page (if that is also a category).
<nowiki>[[</nowiki>{{ns:category}}:'''''<translate><!--T:16-->
Name</translate>''''']]


{{Help:Alphabetic order}}
<translate>
<!--T:17-->
Any number of {{ns:category}} tags may be added to the page and the page will be listed in all of them. {{ns:category}} tags, along with [[Manual:Interwiki#Interwiki_links_to_other_languages|interwiki language links]] placed in the sidebar, are usually added at the very bottom of the page for the convenience of other editors.


== Order of the lists; setting sort keys ==
<!--T:18-->
Each of the three lists is in the order explained above. If you want an item in a list to be positioned in that order, based on an alternative name (sort key) for that item, then this can be specified in the category tag that places the item in the list:
On a categorized page, categories are displayed in the Categories: box strictly in the order they appear in the wikitext.


<nowiki>[[</nowiki>Category:''category name''|''sort key'']]
<!--T:19-->
If $wgUseCategoryBrowser is set to true, under the first list each category is listed again, [[wikipedia:breadcrumb (navigation)|breadcrumb]]-style, with all its parent categories, sorted alphabetically. (At least in MediaWiki 1.18.2) if a category is a subcategory of more than one parent, both hierarchies will be listed, but the tagged category will be stripped off all but one of these. This creates the potential for what appear to be duplicate entries if a category with multiple parents ''and'' one of its parents are both tagged on a page. For example suppose Maryanne is a subcategory of both Mary and Anne. If a page tags categories Maryanne and Anne then the Category breadcrumbs will show
</translate>


For example to add an article called Albert Einstein to the category "people" and have the article sorted by "Einstein, Albert". You would type "<nowiki>[[Category:People|Einstein, Albert]]</nowiki>".
Anne
Anne
Mary -> Maryanne


Although this is like the syntax for a [[Help:Piped link|piped link]] (and in an edit summary it is interpreted like one), there is a clear  difference: the second term in the piped link is an alternative term for the first one, while the sort key is an alternative name for the page in which the tag occurs. Also, a piped link influences the rendering of the page itself, while a sort key affects the rendering of another page.
<translate>
<!--T:20-->
"Anne" appears to be duplicated, but what is meant is
</translate>


The displayed name is not changed, and, unfortunately, only visible on the edit pages of the members of the category. An explanation of the sort key system used can be useful on the editable part of a category page.
Anne
Anne -> Maryanne
Mary -> Maryanne


The sort key system should be obvious, otherwise the order seems random and items are hard to find. The system should either be consistently applied to all members of a category, or be such that the listings of members on which it is applied fit in well within the list of members for which no sort key is used. The latter is advisable for large, growing categories with many contributors. See also below.
<translate>
<!--T:21-->
This is probably a bug, and has been reported in [https://bugzilla.wikimedia.org/show_bug.cgi?id=33614 Bug 33614].


A common system is starting with the last name, then a comma and a space, and then the first name; note that any additions such as "Jr." should come at the end, otherwise the entry would come before the same without the addition, because a space comes before a comma.
===Sort key=== <!--T:22-->


In e.g. [[wikipedia:en:Category:Denmark]], the sort key of a page consists of the keywords, without "Danish" or "of Denmark", "in Denmark", etc.
<!--T:23-->
By default, a page is sorted within a category under the first letter of its name — ''without the namespace''. Also, MediaWiki groups accented characters separately from their unaccented version, so pages starting by À, Á, Ä, will be listed under separate headings, instead of under heading A. (If you have shell access, these defaults can be changed using [[Manual:$wgCategoryCollation|$wgCategoryCollation]].)


The sort key is case sensitive, so a page with the tag <nowiki>[[Category:</nowiki>''Foo''<nowiki>|</nowiki>Zealand]] is sorted before one with the tag <nowiki>[[Category:</nowiki>''Foo''<nowiki>|</nowiki>amsterdam]]. This can be inconvenient, requiring a sortkey in projects with case-sensitivity of the first character if one wants the A and the a together, but if may also be used to one's advantage: e.g., it allows sorting of the pages into two groups, one put in the range A-Z and one in a-z, using sortkeys; see e.g. [[:Category:Demo]], where the help pages are put separately by using sortkeys with lower-case "h".
<!--T:24-->
A ''sort key'' specifies under which letter heading, and where in the category list, the page will appear. You can add a sort key by placing it inside the tag after a pipe character. For example, the tag below will add the page under heading "S".
</translate>


To get the order right, be consistent in punctuation and spacing. For example, "A Z" with two blank spaces comes before "A A" with one.
  <nowiki>[[</nowiki>{{ns:category}}:'''''<translate><!--T:25-->
Name</translate>'''''|'''''<translate><!--T:26-->
Sort</translate>''''']]


An underscore in a page name is equivalent with, and treated as a blank space. However, an underscore in a sort key is distinct from a blank space.
<translate>
<!--T:27-->
Sort keys are case-sensitive, and spaces and other characters are also valid. The order of the sections within a category follows the Unicode sort order. The sort key does not change the page title displayed in the category.


Note that e.g. Ä comes after Z, unless a sort key is used, see e.g. [[de:Special:Allpages/Zz]] and [[wikisource:Special:Allpages/Zu]].
<!--T:28-->
See [[Help:Sorting]] for further information on category sorting.


As seen from the ASCII sequence above, forcing items to the beginning or end can be done with a sort key starting with a space or ~, respectively. Another common sort key for the beginning of the list is the asterisk (*).
==Creating a category page== <!--T:29-->


See also [[bugzilla:2166]].
<!--T:30-->
Categories exist even if their page has not been created, but these categories are isolated from others and serve little purpose for organization or navigation.


==Sort key of images==
<!--T:31-->
Images without sort key are alphabetized according the full name, including namespace prefix "Image:". Therefore, for images for which a sort key is used, the prefix should also be included, otherwise these images are positioned on the category page before "Image:A" or after "Image:Z". Alternatively, ''all'' images can be given a sort key.
A category is created by creating a page in the '''''Category:''''' namespace. A category page can be created the same way as other wiki pages (see [[Help:Starting a new page]]); just add "<code>{{ns:category}}:</code>" before the page title.


Thus a list of images may show a sequence A-I, A-Z, I-Z. One may choose to fix the first and third sequence by adding the prefix to the sort keys, or the second sequence, by putting sort keys without prefix.
<!--T:32-->
To avoid extra work, try searching within your wiki before creating a new category. The list of all categories can be found in "{{int:specialpages}}" in the "{{lcfirst:{{int:toolbox}}}}" box of the [[Help:Navigation#Sidebar|sidebar]].


Similar remarks apply for other non-main namespaces. However, the category namespace is an exception: the default sort key is without prefix, to avoid listing all subcategories by default under the C. Therefore, explicit sort keys should also be without prefix.
<!--T:33-->
Unlike other wiki pages, it is ''not'' possible to rename (move) a category. It is necessary to create a new category and change the {{ns:category}} tag on every page. The new category will ''not'' have the older category's page history, which is undesirable if there are many revisions.


==Grouping of pages by using sortkeys==
==Managing the category hierarchy== <!--T:34--> 
If e.g. in a list of people sortkeys like "scientist Einstein, Albert" are used then all scientists are listed together under the "s". Unfortunately no separate heading "scientist(s)" is possible, and salesmen would be under the same heading. Alternatively "scientist" can have e.g. code K (to be explained in the editable part of the category page) and the sortkey "K Einstein, Albert" is used.


==Labels in the list of images==
<!--T:35-->
As mentioned above, the first 20 characters of the image name are shown, with dots if that is not the full name. This can be inconvenient, e.g. in [[commons:Category:William-Adolphe Bouguereau]] most images have a name starting with "William-Adolphe Bouguereau (1825-1905) -", which are therefore all labeled "William-Adolphe Boug..." (see the last section of the category page).
Categories may belong to other categories in a hierarchy. Since category pages are much like any other page, a {{ns:category}} tag may be added to the bottom of a category page.  


The full names are only shown in the hover box and the status bar, depending on the browser; in the latter possibly with codes such as "%28" for "(".
<!--T:36-->
It is a good idea to organize all categories into a hierarchy with a single top level category. The category structure can take the form of a tree with separate branches, but more often will have a graph structure. Generally, there should be a contiguous chain of parent-child links between each category and the top level category.  


Thus, looking up a name in the alphabetic list is cumbersome. It might have been better to start the names with the shorter "Bouguereau, " and then the title of the painting (unless the software will be improved later).
==Hidden categories== <!--T:37-->


==Alternatives for overviews==
<!--T:38-->
An overview of links to pages and of images by means of thumbnails, can be put in the editable part of a category, just like in any page, or be generated in the second, third and fourth part of the category page.
The categories that a page is in are normally listed at the bottom of the page.
In Mediawiki 1.13+,
a category can be hidden from this list by adding the [[Help:Magic words|magic word]] "<code><nowiki>__HIDDENCAT__</nowiki></code>" to the category page.


The first gives control on structure and lay-out. For example, in the editable part of [[commons:Category:William-Adolphe Bouguereau]] the name of the painter does not have to be repeated, and the full titles of the paintings can be shown.
<!--T:39-->
Users can choose to see hidden categories in a separate "{{int:hidden-categories}}" list, by checking "{{int:tog-showhiddencats}}" in the "{{int:prefs-rendering}}" section of [[Special:Preferences]].


The second is more convenient for new pages/images: by putting the category tag (which for images can even be done in the [[Help:Edit_summary#Upload_summary|upload summary]]) the overview is automatically updated. Also, the sorting in alphabetic order is automatic in the second case.
<!--T:40-->
Hidden categories are automatically added to [[:Category:{{mediawiki:hidden-category-category}}]]. This category is specified in the system message [[MediaWiki:Hidden-category-category]].


A category page may have an overview in the first part, as well as in one or more of the other parts, with the following possibilities:
<!--T:41-->
*items occur twice, but ordered and structured differently, with different info (including that the fourth section shows the file sizes); when creating/uploading new items, they can be put in the category first, which is a convenient intermediate stage for updating the editable part
''See also:'' [[m:Help:Category#Hidden_categories|hidden categories]]
*avoiding duplications


Anyway, a category has the double functionality of allowing extension of the overviews both from the overview page and from the member pages. This convenience makes it easier to build and maintain a complete overview (albeit divided over sections) for the subject concerned.
==Linking to a category== <!--T:42-->


If the second, third and fourth part of the category page are not used than the category page is much like a page in another namespace. Differences are:
<!--T:43-->
*the name starts with "Category:"
To create a link to a category, use a leading colon before the category name (without this colon, the current page would be added to the category):
*in ordinary links to the category page the name is preceded by a colon
*Related Changes does not work for the editable part


If a category is growing too large, it is cumbersome to split. When new items need to be added, and they are on a subtopic about which there is still little in the category, this is a good occasion to start a subcategory. Other kinds of overview can be split more easily.
<!--T:44-->
:<code><nowiki>[[</nowiki>:{{ns:category}}:Help]]</code> &rarr; '''[[:{{ns:category}}:Help]]'''


See also [[commons:Commons:Images on normal pages or categories:Vote]].
<!--T:45-->
To change the link text, write the text inside the link tag after a pipe:


== Linking to a category ==
<!--T:46-->
:<code><nowiki>[[</nowiki>:{{ns:category}}:Help|Help category]]</code> &rarr; '''[[:{{ns:category}}:Help|Help category]]'''
[[Help:Redirects|Redirect pages]] that redirect to categories must also use the colon, otherwise they will be added to the category instead of redirecting.


If you want to link to a category without the current page being added to it, you should use the link form <nowiki>[[:Category:</nowiki>''foobar''<nowiki>]]</nowiki> (where ''foobar'' is the category name). Note the extra ''':''' before Category.
==Redirecting a category== <!--T:47-->


== Existing categories ==
<!--T:48-->
Like normal wiki pages, category pages can be redirected to other normal or category pages. ''However'', this is not recommended, as pages categorized in redirected categories do ''not'' get categorized in the target category ([[:bugzilla:3311]]). Some Wikimedia sites use a "category redirect" template to mark redirected categories, allowing manual or automated cleanup of pages categorized there.


You can see currently used categories for each project with  '''[[Special:Categories]]''', for Wikipedia [[en:Special:Categories]]. It produces a list of all categories, including those which contain subcategories or pages, but have no additional text, as opposed to Special:Allpages for the Category namespace (on Meta: [http://meta.wikimedia.org/w/index.php?title=Special%3AAllpages&from=&namespace=14]), which does not include the latter. In that case a link to the category page shows up as link to a non-existing page that leads to the edit page. Even with preview this does not show the pages etc. in the category; use Cancel or, better, add a supercategory and/or other text, and save, to see the pages in the category.
==Tracking categories== <!--T:49-->


Navigation is by number in alphabetic order, not by starting letter. For projects with thousands of categories this is cumbersome.
<!--T:50-->
Certain syntax issues, such as a broken image link, or too many expensive parser functions, can cause a page to be added to a tracking category. See [[Help:Tracking categories]] for details.


==A category tag in a template; caching problem==
==See also== <!--T:51-->


If a template contains the code indicating that it is in a category, this does not only put that template in the category, but also the pages that include the template. For example, this page includes [[Template:Hh]] and as a result is in [[:Category:English documentation]].
</translate>
* [[Special:MyLanguage/Category:Category extensions|Category:Category extensions]]


The page that contains the template correctly lists the categories to which it belongs. However, adding or deleting a category tag in the template does not add or delete the listings on the category page of pages that use the template, until some edit is made in the page that uses the template.
[[Category:Help{{translation}}|Categories]]
 
[[Category:Category{{translation}}]]
In other words:
 
*lists of categories a page is in, are up-to-date
*lists of pages in a category are based on the situation just after the last edit of the pages
 
Since adding or removing a category or template tag is obviously an edit there is only a complication when a page is indirectly added to or deleted from a category, through a change in a template the page uses.
 
To refresh category pages with respect to the listing of a particular page (adding or deleting the entry), a [[Help:Editing#Dummy edit and null edit|null edit]] can be applied to that page: just applying section edit and saving without changes.
 
===Sort key===
A sort key in a category tag in a template applies to the template as well as to the pages that use it, so it is only useful if it is variable. It can depend on a variable (notably PAGENAME), parameter, or the content of a template.
 
==Categorizing templates themselves==
To categorize templates themselves, without the pages that call them, one could consider putting the category tag in the talk page of the template, and an explanation on the category page that the template talk pages listed are meant as categorization of the templates.
 
==A category name depending on a template or parameter==
 
A category name can depend on a template or parameter, just like the target of other links, see [[Template:Cat]] and [[Template talk:Cat]].
 
==Comparison with "What links here"==
 
[[Help:What links here|Backlinks]] are often used as a by-product of links. However, links can be put specially for the backlinks, just like category tags are. In that case a redirect corresponds to a supercategory.
 
Advantages of categories:
*Category listings are alphabetical, for "What links here" this typically applies for the first part only, for the pages already linking to the given page at the time of the last rebuilding of the link tables in the database.
*Categories have an editable part (however, there is anyway a talk page)
*A category can have multiple supercategories
 
Advantage of a pseudo-category system using backlinks:
*Backlinks can show a tree structure: not only pages and subcategories, but also the contents of the subcategories (for each a list of pages and a list of sub-subcategories) and the contents of the sub-subcategories (for each a list of pages and a list of sub-sub-subcategories), but not the contents of the sub-sub-subcategories, up to three levels are shown; see [[Special:Whatlinkshere/Altcat:Help|Cat:Help]] and [[wikipedia:en:Special:Whatlinkshere/Cat:Municipalities of the Netherlands|Cat:Municipalities of the Netherlands]].
 
Alternatively a template (either a dummy one, specially for this purpose, or one with contents) can function as a supercategory, used in connection with backlinks. In that case:
*also multiple supercategories are possible
*combined content of subcategories is shown in one list, not grouped by subcategory (the tree structure is not shown, but it can be used by taking the backlinks at a lower node, showing the smaller set)
*the restriction of three levels (in the case of using redirects) does not apply; for example page Aijkl in the category Aijk in the category Aij in the category Ai in the category A (represented by Aijkl calling template Aijk, etc.) can be shown in the list of pages in category A (the backlinks of template A).
 
"What links here" tends to be a by-product of links that are useful anyway (although links may be put with this use in mind), while category links are put specially to produce a category page.
 
Putting a category tag on a test page, user page, etc. (also if done indirectly by including a template with a category tag) is considered to pollute the category, while regular links from such pages showing up in "what links here"  is considered harmless.
 
Therefore:
*when copying text to such pages, category tags have to be removed; alternatively, convert the category to a link by adding a leading colon after the brackets.  For example, <nowiki>"[[:Category:Art]]"</nowiki> is a link to the category, ''not'' an assignment to a category.
*when including a template that is in a category, do not use the template feature, but use "subst" or copy-and-paste, and delete the category tags.
 
==Applying "What links here" and "Related Changes" to a category==
 
For the "What links here" feature, only the links in the editable part of the page count, not the links to the pages in the category.
 
Before 1.4: ditto for the "Related Changes" feature.
 
From 1.4: For a category, the "Related Changes" feature gives the changes in the pages in the category (according to the current category page, so excluding the pages that have potentially been added and including those that have potentially been removed, through addition or deletion of a template to/from the category, as explained above)
*for subcategories: the changes in their editable parts only
*for images (image pages): the changes in their editable parts only.
 
It does ''not'' show the changes in pages linked from the editable parts of the category. Possible workarounds:
*The editable part can be put in a template. The category tags (which have no effect on Related Changes anyway) can better be kept out of the template, because on the pages of these supercategories the template would be listed under the articles in those  categories. Whether interwiki links (with or without interlanguage link feature) are in the template or not does not make a difference, provided that the template is not used elsewhere.
*Related Changes is applied to a page that calls the category as a template: <nowiki>{{:Category:</nowiki>''Category name''}}; only the editable part is included in the page; the page could be specially created for this purpose and call multiple categories. However, this page will then be listed in the supercategory pages of each category.
 
As usual (but as opposed to a watchlist) the changes in the corresponding talk pages are not shown.
 
==Detection of additions to a category==
With "Related Changes" one can find pages which are newly in a category due to addition of a category tag or the tag of a template that is in the category. Addition of pages through addition to the category of a template is seen indirectly: one can see the change in the template, and then check which pages call the template. This even shows pages which are only potentially in the category (see above).
 
==Detection of deletions from a category==
Unfortunately there is no similar way to detect a deletion from a category.
 
== Conventions and project-specific settings ==
Each page is typically in at least one category. It may be in more, but it may be wise not to put a page in a category and also in a more general category.
 
Each category, except one top-level category, is typically in at least one higher level category.
 
Check the conventions in a project and make yourself familiar with the categories in use before assigning pages and subcategories to categories and before creating new categories.
 
For category names the usual rules for [[Help:Page_name#Case-sensitivity|case-sensitivity]] of page names apply: they are case-sensitive beyond the first character, but in most projects the first character is case-insensitive. So be aware that you create a new category if the capitalization beyond the first character is not the same.
 
== How categories are implemented ==
''(partly repeating the above)''
 
Each of the pages in the '''Category''' [[Help:Namespace|namespace]] represents a so-called '''category''', a kind of grouping of related pages.
For example, this page belongs to "[[:Category:English documentation]]".
When a page belongs to one or more categories, this information appears at the bottom of the page (or in the upper-right corner, depending on the [[Help:Preferences|skin]] being used).
 
The page of the category contains text that can be edited, like any other page, but when displaying the page, the last part of what is displayed is an automatically generated, alphabetical list of all pages in that category, in the form of links (in fact ASCII order, see [[Help:Special page]]).
 
For a complete list of categories, see [[Special:Categories]]. Individual wikis may have their own top-level categories, such as [[wikipedia:en:Category:Categories]] in Wikipedia. For categories in Meta-Wiki, see [[Meta:Categories]].
 
New categories can be [[Help:Starting a new page|created]] and [[Help:Editing|edited]] in the same way as any other regular page&sup1;, but when displayed, an automatically generated, alphabetical list of all pages in that category appears at the bottom.
 
You can assign a category to a page simply by adding "<nowiki>[[</nowiki>Category:''categoryname'']]" to the page's [[wikitext]] source. Substitute the actual name of the category in place of ''categoryname''.
 
To be specific, in order to add an article called "Albert Einstein" to the category "People", you would edit the article and add "<nowiki>[[</nowiki>Category:People]]" (no quotes) into its page source somewhere. Exactly where doesn't matter, but the Wikipedia policy, for example, is to put it ''after'' the article text, but ''before'' any [[Help:Interwiki linking|interlanguage links]].
 
==Category page note==
You can include the template [[template:category note]] <nowiki>{{category note}}</nowiki> into the category page's description,  which can link to your [[:category:top_level|top level]] category and include basic help.
 
=== here it is for this site ===
{{category note}}
<br clear=right>
 
==Large categories==
If a category is large, there are multiple pages. A page with e.g. the  name range Leiden-Rotterdam shows the subcategories, articles and images in that range, together up to 200. Somewhat confusingly, the subcategory count and article count apply to that name range. The editable part of the page is repeated on each of the set of pages.
 
To start the list at a given name, use a URL like http://en.wikipedia.org/w/index.php?title=Category:American_actors&from=Ford
 
A category TOC with such links can be useful. If foreign or otherwise special characters occur, it seems best to order the TOC in accordance with their position in the full list. For example É could be positioned:
*at E (sortkey of Échange is Echange)
*between E and F (sortkey of Échange could be E~change or "F  change" with two spaces)
*after Z (system order, i.e. the order if no sortkeys are used)
 
If É in the TOC is between E and F but no sort keys are used, it is confusing that when following the link Z, at the end there are pages starting with É.
 
Examples of large categories:
*with mainly articles: [[wikipedia:en:Category:American actors]]
*with mainly images: [[wikipedia:en:Category:Public domain images]]
 
See also:
*[[wikipedia:en:Latin_alphabet#Collating_in_other_languages|collating]]
*[[wikipedia:en:Categorization#Category_sorting|category sorting]]
*[http://de.wikipedia.org/wiki/Bild_Diskussion:Logo_Begriffskl%C3%A4rung.png#commons:Template:CategoryTOC.2C_en:Template:CategoryTOC.2C_en:Template:CatAZ list of category TOCs in various Wikipedias]
*{{timc|A-Z}} (see the Talk page for other versions)
 
==Multiple tags for adding a page to a category==
Multiple tags for adding a page to a category do not cause multiple listing in the category page, not even if different sortkeys have been specified: only the last tag is effective (also, if that has no sortkey, this overrides a sortkey specified in a previous tag). See [[Help:Demo 1]].
 
==Editing==
The preview of the edit page of a category only shows the editable part, not the list of pages in the category, etc.
 
==Category flattening==
 
There has been some discussion about implementing category flattening. This means, that optionally a category page also displays articles in its subcategories, sub-subcategories, etc. See [[m:Category flatten]] and [http://bugzilla.wikimedia.org/show_bug.cgi?id=1497].
 
==Usage==
"Is a member of" can be any [[wikipedia:en:binary relation|binary relation]] over the set of all pages and the set of categories,
When we consider the subcategory relation, we consider the [[wikipedia:en:Function_%28mathematics%29#Restrictions_and_extensions|restriction]] (subset) of the binary relation, to one over the set of categories only. It is a [[wikipedia:en:Graph_%28mathematics%29#Directed_graph|directed graph]].
 
Usually categories are applied in such a way that page A (hence, in particular, category A) is directly or indirectly a member of category B if and only if the set of information about A is a subset of the set of information about B. This would imply that categories form a [[wikipedia:en:directed acyclic graph|directed acyclic graph]].
 
Nevertheless, occasionally a category cycle may occur such as:
 
Humans->Apes->Primates->Mammals->Animals->Tree of life->
Biology->Science->Human societies->Humans
 
In this case the cycle is due to a shift from the object of study, through the activity of studying, to the beings doing the study: the seemingly wrong arrangement with the info about animals supposedly being a subset of the info about humans represents the fact that humans study animals.
 
See also [[wikipedia:en:Categorization]] and its talk page.
 
==Lists versus categories==
For a comparison see:
*[[:Category:Demo]] and [[Category talk:Demo]] (a corresponding list).
*[[wikipedia:en:Merge lists to categories]]
*[[wikipedia:en:Category:Lists that should be categories]]
 
==See also==
 
*Categories in this project: [[Project:Categories]] {{h:|(includes a warning about creating new categories) and [[:Category:Top level]]}}
*[[wikipedia:en:Category]]
*[[Categorization]]
*[[wikipedia:en:Wikipedia:Category schemes]]
*[[commons:Commons:Images on normal pages or categories:Vote]]
*[[:sr:Википедија:Tests for Корисник:Bonzo]]

Revision as of 23:16, 9 October 2014

<languages/> {{#invoke:Template translation|renderTranslatedTemplate|uselang=|namespace=|template={{#if:|{{{template}}}|PD Help Page}}|noshift=}} <translate> Categories, a software feature of MediaWiki, provide automatic indexes that are useful as tables of contents.

You can categorize pages and files by adding one or more Category {{#ifeq:Category|Category||(Category)}} tags to the content text. These tags create links at the bottom of the page that take you to the list of all pages in that category, which makes it easy to browse related articles.

Summary

Each of the pages in the Category namespace represents a so-called category, a grouping of related pages, and contains an index for the pages of its category. For example, this page belongs to "Category:Help". If you open the "Category:Help" page, you will see a link to this page there.

When a page belongs to one or more categories, these categories appear at the bottom of the page (or in the upper-right corner, depending on the skin being used).

The category pages themselves contain 2 parts:

  • at their beginning, an optional part may contain text that can be edited, like any other page,
  • at their end, an ever present, automatically generated, alphabetical list of all pages in that category, in the form of links. (In fact, in ASCII order. See Help:Special page).

To assign a category to a page, simply add the link "[[Category:Category name]]" to the page's wikitext. The usual place to add it is at the bottom of the page.

To link a category page within a page as a normal wiki link (without adding the page to the category), prefix the link name with a colon. For example: [[:Category:Not in this category]]

New categories can be created before assigning any page to it, in the same way as any other regular page.

Individual wikis may have their own top-level categories, such as Category:Contents in Wikipedia.

For a complete list of all categories which have at least one page, see Special:Categories.

For a complete list of all created/edited categories, including the ones that don't have any pages, see Special:Allpages/Category: (note the colon at the end).

Adding a page to a category

To add a page or uploaded file to a category, simply edit the page and add the following text (where Name is the name of the category you want to add it to). </translate>

[[Category:<translate>

Name</translate>]]

<translate> Any number of Category tags may be added to the page and the page will be listed in all of them. Category tags, along with interwiki language links placed in the sidebar, are usually added at the very bottom of the page for the convenience of other editors.

On a categorized page, categories are displayed in the Categories: box strictly in the order they appear in the wikitext.

If $wgUseCategoryBrowser is set to true, under the first list each category is listed again, breadcrumb-style, with all its parent categories, sorted alphabetically. (At least in MediaWiki 1.18.2) if a category is a subcategory of more than one parent, both hierarchies will be listed, but the tagged category will be stripped off all but one of these. This creates the potential for what appear to be duplicate entries if a category with multiple parents and one of its parents are both tagged on a page. For example suppose Maryanne is a subcategory of both Mary and Anne. If a page tags categories Maryanne and Anne then the Category breadcrumbs will show </translate>

Anne 
Anne
Mary -> Maryanne

<translate> "Anne" appears to be duplicated, but what is meant is </translate>

Anne 
Anne -> Maryanne
Mary -> Maryanne

<translate> This is probably a bug, and has been reported in Bug 33614.

Sort key

By default, a page is sorted within a category under the first letter of its name — without the namespace. Also, MediaWiki groups accented characters separately from their unaccented version, so pages starting by À, Á, Ä, will be listed under separate headings, instead of under heading A. (If you have shell access, these defaults can be changed using $wgCategoryCollation.)

A sort key specifies under which letter heading, and where in the category list, the page will appear. You can add a sort key by placing it inside the tag after a pipe character. For example, the tag below will add the page under heading "S". </translate>

[[Category:<translate>

Name</translate>|<translate> Sort</translate>]]

<translate> Sort keys are case-sensitive, and spaces and other characters are also valid. The order of the sections within a category follows the Unicode sort order. The sort key does not change the page title displayed in the category.

See Help:Sorting for further information on category sorting.

Creating a category page

Categories exist even if their page has not been created, but these categories are isolated from others and serve little purpose for organization or navigation.

A category is created by creating a page in the Category: namespace. A category page can be created the same way as other wiki pages (see Help:Starting a new page); just add "Category:" before the page title.

To avoid extra work, try searching within your wiki before creating a new category. The list of all categories can be found in "Special pages" in the "tools" box of the sidebar.

Unlike other wiki pages, it is not possible to rename (move) a category. It is necessary to create a new category and change the Category tag on every page. The new category will not have the older category's page history, which is undesirable if there are many revisions.

Managing the category hierarchy

Categories may belong to other categories in a hierarchy. Since category pages are much like any other page, a Category tag may be added to the bottom of a category page.

It is a good idea to organize all categories into a hierarchy with a single top level category. The category structure can take the form of a tree with separate branches, but more often will have a graph structure. Generally, there should be a contiguous chain of parent-child links between each category and the top level category.

Hidden categories

The categories that a page is in are normally listed at the bottom of the page. In Mediawiki 1.13+, a category can be hidden from this list by adding the magic word "__HIDDENCAT__" to the category page.

Users can choose to see hidden categories in a separate "Hidden categories" list, by checking "Show hidden categories" in the "Appearance" section of Special:Preferences.

Hidden categories are automatically added to Category:Hidden categories. This category is specified in the system message MediaWiki:Hidden-category-category.

See also: hidden categories

Linking to a category

To create a link to a category, use a leading colon before the category name (without this colon, the current page would be added to the category):

[[:Category:Help]]Category:Help

To change the link text, write the text inside the link tag after a pipe:

[[:Category:Help|Help category]]Help category

Redirect pages that redirect to categories must also use the colon, otherwise they will be added to the category instead of redirecting.

Redirecting a category

Like normal wiki pages, category pages can be redirected to other normal or category pages. However, this is not recommended, as pages categorized in redirected categories do not get categorized in the target category (bugzilla:3311). Some Wikimedia sites use a "category redirect" template to mark redirected categories, allowing manual or automated cleanup of pages categorized there.

Tracking categories

Certain syntax issues, such as a broken image link, or too many expensive parser functions, can cause a page to be added to a tracking category. See Help:Tracking categories for details.

See also

</translate>

[[Category:Help{{#ifeq:

 {{#titleparts:help:category|1|-1}}

| {{#titleparts:help:category|1|-1}} | | /{{#titleparts:Help:Category|1|-1}} }}|Categories]] [[Category:Category{{#ifeq:

 {{#titleparts:help:category|1|-1}}

| {{#titleparts:help:category|1|-1}} | | /{{#titleparts:Help:Category|1|-1}} }}]]