Skip to content

MediaWiki Categories — Tree Categories, Category Sorting, and Hidden Categories

DodaTech Updated 2026-06-26 9 min read

In this tutorial, you will learn about MediaWiki Categories. We cover key concepts, practical examples, and best practices to help you master this topic.

Categories in MediaWiki are a hierarchical tagging system that groups related pages by topic, enabling automatic indexes, category trees, custom sorting, and hidden categories — the same organizational backbone that Wikipedia uses to classify its millions of articles into a browsable structure.

What You'll Learn

  • Adding categories to pages and creating category pages
  • Building category hierarchies with parent categories
  • Controlling sort order within categories
  • Creating hidden categories for administrative use
  • Using category template tags and category links
  • Managing the category system at scale

Why It Matters

A wiki without categories is a pile of unrelated pages. Readers cannot find related content. Search is the only navigation option. Categories turn a flat list of pages into an organized library. A "Documentation" category gathers all help pages. Subcategories like "Installation Guides" and "API References" break it into manageable sections. Readers browse the category tree to discover content they did not know existed.

Real-World Use

A DodaTech product wiki uses a three-level category hierarchy:

Products
  ├── DodaTech Browsers
  │   ├── DodaBrowser
  │   └── DodaBrowser Pro
  ├── DodaTech Utilities
  │   ├── DodaZIP
  │   └── DodaSync
  └── DodaTech Security
      └── Durga Antivirus Pro

Each product page is sorted by its version number within the product category, and a hidden "Deprecated" category tracks outdated pages that should be removed.

Learning Path

flowchart LR
  A["15: Subpages"] --> B["16: Redirects"]
  B --> C["17: Categories"]
  C:::current
  D["18: Special Pages"]
  E["19: Watchlist"]
  F["20: User Groups"]

  C --> D --> E --> F

  classDef current fill#38bdf8,color#0f172a,stroke-width:2px

Step 1: Add a Category to a Page

Adding a category is as simple as adding a link at the bottom of any page:

[[Category:Documentation]]

This does two things:

  1. A link to "Category:Documentation" appears at the bottom of the page
  2. The page is listed on the Category:Documentation page

Multiple Categories

A page can belong to multiple categories:

[[Category:Tutorials]]
[[Category:MediaWiki]]
[[Category:Beginner Guides]]

The page appears in all three category listings. Use multiple categories when a page covers multiple topics.

The [[Category:Name]] syntax creates an actual category membership. If you want to link to a category page WITHOUT adding the current page to that category, use a colon prefix:

[[:Category:MediaWiki|MediaWiki category]]

This creates a clickable link to the category page without tagging the current page. The colon before "Category" tells MediaWiki to treat it as a link, not a tag.

Step 2: Create a Category Page

When you add [[Category:Documentation]] to a page, the "Documentation" category page is auto-created as a red link. Click it to add content.

A category page lists all pages in that category automatically. You can add descriptive text above the listing:

= Documentation =

This category contains all documentation-related pages.

== Subcategories ==

[[Category:Documentation]] should contain:
* [[:Category:Installation Guides]] — step-by-step installation instructions
* [[:Category:API References]] — technical API documentation
* [[:Category:FAQs]] — frequently asked questions

[[Category:Top Level]]

The auto-generated section shows:

  • All pages in the category (alphabetically sorted)
  • All subcategories
  • The page count: "(3 members)"

Step 3: Build a Category Tree

Categories can have parent categories, creating a tree structure.

To make "Installation Guides" a subcategory of "Documentation", add this to the "Installation Guides" category page:

[[Category:Documentation]]

Now the category tree looks like:

Category:Documentation
  ├── Category:Installation Guides
  ├── Category:API References
  └── Category:FAQs

Viewing the Category Tree

Use Special:CategoryTree to see any category's hierarchy in an expandable tree view. Add it to any page:

<categorytree mode=pages>Documentation</categorytree>

The mode parameter controls what is shown:

  • pages — Show pages and subcategories
  • subcategories — Show only subcategories
  • all — Show all content including files

Category pages show breadcrumbs automatically. For Category:Installation Guides with parent Category:Documentation, the breadcrumb shows:

Category:Documentation > Installation Guides

Each parent is clickable, allowing readers to navigate up the category tree.

Step 4: Control Sort Order

By default, pages are sorted alphabetically by their full title within a category. Control the sort key with a pipe:

[[Category:Documentation|Installation Guide]]

Even if the page is titled "DodaBrowser — Installation Guide," it appears under "I" for "Installation Guide" in the category listing.

Sort Key Conventions

Common approaches to sorting:

  • By topic: [[Category:Tutorials|Basics, MediaWiki]] — groups all tutorials by topic
  • Ignore articles: [[Category:Products|DodaBrowser, The]] — sorts by the main word
  • By version: [[Category:Versions|2026.1]] — sorts by numeric version
  • By author: [[Category:Authors|Smith, John]] — sorts by last name for a staff directory

Default Sort Key with DEFAULTSORT

Use {{DEFAULTSORT:}} to set a default sort key for all categories on a page:

{{DEFAULTSORT:Installation Guide, DodaBrowser}}

With this at the top of the page, ALL category tags on that page use "Installation Guide, DodaBrowser" as their sort key unless overridden individually.

Step 5: Hidden Categories

A hidden category does not appear in the category links at the bottom of pages. Use hidden categories for administrative tracking.

Make a category hidden by adding __HIDDENCAT__ to its category page:

= Deprecated Pages =

Pages in this category are marked as deprecated.

__HIDDENCAT__
[[Category:Wiki Maintenance]]

Now, pages tagged with [[Category:Deprecated Pages]] do not show the category link at the bottom. However, the category page still exists and can be viewed.

Use Cases for Hidden Categories

  • Deprecated content: Pages that should be updated
  • Stubs: Pages that need expansion
  • Reviewed pages: Pages that passed a quality review
  • Templates with specific behaviors: Template tracking categories
  • Internal projects: Wiki maintenance tracking

Step 6: Category Template Tags

Templates can automatically add categories to pages. This is powerful — when a user adds a template to a page, the category is assigned without the user needing to know about the category system.

In Template:Stub:

<div class="notice">This article is a stub. You can help by expanding it.</div>
<includeonly>[[Category:Stubs]]</includeonly>

Any page using {{Stub}} is automatically added to the Stubs category without the editor writing [[Category:Stubs]].

Tracking Categories

Create a hidden tracking category for template usage:

<includeonly>[[Category:Pages using the Alert template]]</includeonly>
<noinclude>
[[Category:Template documentation]]
</noinclude>

The template automatically tracks where it is used, which is helpful for monitoring template usage and finding pages that need template updates.

Step 7: Category Management

Special:UncategorizedPages

Lists all pages without any category. Review this regularly to ensure every page is categorized.

Special:UncategorizedCategories

Lists category pages that are not themselves categorized. Every category should belong to a parent category.

Special:WantedCategories

Lists categories that are linked but have no category page. Create the missing category pages.

Category Collation

Category collation controls how characters are sorted. Chinese, Japanese, and Korean wikis need special collation. Configure in LocalSettings.php:

$wgCategoryCollation = 'uppercase';

Options include uppercase, numeric, identity (no transformation).

What You Learned

  • [[Category:Name]] adds a page to a category
  • Category pages show all members and subcategories
  • Subcategories create a tree hierarchy
  • Sort keys control ordering within categories
  • {{DEFAULTSORT:}} sets the default sort key for all categories on a page
  • __HIDDENCAT__ hides a category from page footers
  • Templates can add categories automatically with <includeonly>

In the next lesson, you'll explore Special pages — built-in pages that provide administrative tools and wiki statistics.

Common Mistakes

| Mistake | Why It Happens | How to Fix | |---------|---------------|------------| | Category link appears at bottom of page instead of adding to category | Missing colon in [[:Category:Name]] | Use [[Category:Name]] (no leading colon) to add to a category. Use [[:Category:Name]] to link to a category page. | | Page sorts under wrong letter in category listing | No sort key set, using full page title | Add a sort key: [[Category:Name|SortKey]]. Use {{DEFAULTSORT:}} for global sorting. | | Category shows no subcategories even though they exist | Subcategory tag not added to the child category page | Go to the child category page and add [[Category:ParentName]]. Subcategories are not automatic. | | Hidden category still visible on pages | __HIDDENCAT__ added to pages instead of the category page | __HIDDENCAT__ goes on the CATEGORY page (e.g., Category:Deprecated), not on pages tagged with that category. | | Template adds category but it appears on the template page itself | Missing <includeonly> tags | Wrap the category tag in <includeonly>. Otherwise, the template page itself is categorized. | | Category page shows broken links to deleted pages | Pages removed but not recategorized | Visit Special:WantedCategories and clean up categories that no longer have content. Categories are updated automatically when a page is deleted. |

Practice Questions

  1. What is the difference between [[Category:Documentation]] and [[:Category:Documentation]]?
  2. How would you make a page appear under "B" in a category listing even though its title starts with "D"?
  3. What is a hidden category and when should you use one?
  4. Challenge: Build a complete category system for a company wiki. Create a hierarchy with at least 3 top-level categories (Products, Documentation, Internal). Under Products, create subcategories for each DodaTech product (DodaBrowser, DodaZIP, DodaSync, Durga Antivirus Pro). Under Documentation, create subcategories for Guides, Tutorials, and API References. Create 2-3 pages for each leaf category with appropriate sort keys. Add a tracking template called "Under Review" that adds pages to a hidden "Pages Under Review" category. Finally, use Special:UncategorizedPages to ensure no pages are missing categories.

FAQ

Can a page belong to more than one category?

Yes. A page can be in any number of categories. Add multiple [[Category:...]] tags at the bottom of the page. Each category's listing will include the page. This is common for cross-topic pages.

What is the maximum number of categories a page can have?

There is no hard limit, but practical limits apply. Each category adds a database entry. Having 100+ categories on a single page makes the category listing at the bottom unusably long. 3-8 categories per page is a reasonable range.

How do I rename a category?

Rename a category by moving the category page. After moving, update all pages that use the old category tag. Use Special:ReplaceText extension (or a similar tool) to batch-update [[Category:OldName]] to [[Category:NewName]] across all pages.

Can categories have descriptions or templates?

Yes. Category pages support any wikitext. You can add templates, images, navigation boxes, or descriptions above the auto-generated member list. This is useful for documenting what belongs in the category.

What is the difference between categories and subpages for organizing content?

Categories group pages by topic (cross-cutting). Subpages create parent-child hierarchies (sequential). Use both together: subpages for document structure and categories for topic classification. A page can be in multiple categories but only one subpage tree.

Mini Project

Goal: Build a complete category system for a product documentation wiki.

  1. Create top-level category "Products" with description text
  2. Create subcategories under Products: "DodaTech Browsers," "DodaTech Utilities," "DodaTech Security"
  3. Create 2 product pages in each subcategory with appropriate category tags and sort keys
  4. Add {{DEFAULTSORT:}} to one page and verify it affects all its category listings
  5. Create a hidden category "Deprecated Products" with __HIDDENCAT__
  6. Create a template called "Beta" that adds pages to a "Beta Products" category
  7. Verify the category tree using Special:CategoryTree
  8. Use Special:UncategorizedCategories to check for uncategorized categories
  9. Add all product pages to the "Products" category in addition to their subcategories

What's Next

Categories organize your content. Now let's explore the built-in tools that help you manage and monitor your wiki.

Continue to Lesson 18: Special Pages — learn about MediaWiki's special pages for administration, statistics, and content management.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro