Help:Understanding and Using Wiki Categories
From StcWiki
Wiki categories are a feature of MediaWiki that allow you to group pages together by a given topic or theme. They can also be nested to create categories within categories. For that reason they are useful for establishing an overall content structure in the wiki, along with a general navigation system between them.
There are no categories in MediaWiki by default. You have to actually create them.
Contents |
[edit] Category Tag Syntax
Categories are created using the category: namespace prefix before the name, which is how MediaWiki knows it's a category.
The tag syntax to use is...
-
[[category:Category Name]]
...where "Category Name" is the actual name intended.
[edit] Category Function/Behavior
[edit] Page Indexation
The primary function of a category is to add the current page (the one your adding the category tag to) into the category you are creating (or an existing category if it already exists).
When a category has been designated with even just a single page, MediaWiki generates an index page for the category and the page(s) are organized alphabetically by title.
Whenever a page has been assigned to a category, MediaWiki will generate a link to the category index, which is always displayed at the bottom of the page. If an article page belongs to more than one category (often the case), a link to each category index will be visible.
You don't have to have a category already existing before you can add a page to it. You can actually associate a page to a new category, thereby creating the new category in the process.
Note: When adding category tags to a page (to effectively categorize the page), you should always add them to the bottom of the page. This is because even though category tags used for indexation do not appear where you put them when the page is saved, they are still there in the code and take up space. They are also subject to be accidently edited by other authors if it's not clear where they are at. As such, a good convention is to always keep them at the bottom of the page, which is consistent with how MediaWiki displays them anyway.
[edit] Subcategorization (Nesting Categories)
Category tags can also be added to other category index pages, thereby creating subcategories. The direction to which you add categories might seem a little backwards at first, but basically you add the category tag that will be the parent category to the index page of the child category. This tells the child category index that is should appear as a subcategory link option in the parent category index.
For example, let's say you have three categories -- Fruit, Berries and Melons -- and you want Berries and Melons to be subcategories of Fruit. At the bottom of the Berries and Melons category pages you would add the following tag: [[category:Fruit]]. Links to the Berries and Melons categories would then appear in the Fruit category as subcategory options. As long as all associated fruit pages (Blueberries, Strawberries, Watermelon, Casaba, etc.) were tagged accordingly, everthing falls into place nicely.
[edit] As Inline Links to Category Indexes
You can force a category tag to appear inline and function just like a normal page link. This is useful if you are referring to a particular category index and want to provide a convenient link to it in context.
To force a category tag to function as a visible link, simply add a colon (:) to the front of the namespace. For example:
-
[[:category:Category Name]].
Note this also removes the function of adding the page to the category, so if you want to add the page to the category and show the link in another instance somewhere in the page, you need to add the category tag twice, once conventionally and once as a forced link.
[edit] Strategic Use as Wiki Navigation
If a wiki project is approached early on with the idea of using categories to organize wiki content into sections (as if it was a regular web site), then it's easy to think of using the category nesting technique as the hierarchical depth of the structure, and the first-level categories would be the links provided under the navigation list in the left column. A user would click one of those links, arrive at the category index page and see content for that topic, and could follow deeper level categories as necessary.
Effectively you have a structure like below which is well-suited to a typical site navigation model:
Category L1
- Category L2
- Page
- Page
- etc
- Category L2
- Page
- Page
- etc
Category L1
- Category L2
- Page
- etc
- Category L2
Category L1
- Category L2
- Category L2
Since every page associated to a category has a link to that category at the bottom of the page, it's easy to navigate back up the structure. Additionally, for small groups of pages, custom navigation templates can be used to provide additional navigation lists to traverse pages horizontally.

