MediaWiki Advanced Wikitext — Tables, Lists, Collapsible Sections, and Magic Words
In this tutorial, you will learn about MediaWiki Advanced Wikitext. We cover key concepts, practical examples, and best practices to help you master this topic.
Advanced wikitext in MediaWiki includes tables with sorting, nested and definition lists, collapsible sections, magic words for page metadata, and conditional content that transforms static pages into dynamic documents — the same techniques used on Wikipedia for complex infoboxes and navigation templates.
What You'll Learn
- Creating sortable tables with row and column spans
- Building nested lists, definition lists, and mixed lists
- Adding collapsible sections for long content
- Using magic words for page behavior and metadata
- Combining these techniques in a real documentation page
Why It Matters
Wikitext is the language of MediaWiki. The basic syntax gets you started, but advanced wikitext is what separates a plain wiki from a professional one. Sortable tables let readers reorder data. Collapsible sections keep long pages manageable. Magic words give you control over how pages behave. These are the tools Wikipedia editors use every day to create those polished, information-rich pages.
Real-World Use
A DodaTech product documentation page uses a sortable table listing all API endpoints with versions, status, and deprecation dates. Below it, a collapsible section hides verbose changelog entries until the reader clicks "Expand." Magic words handle automatic category sorting and prevent the page from appearing in search results during a draft review.
Learning Path
flowchart LR A["01: What is MediaWiki?"] --> B["02: Installation"] B --> C["03: First Page"] C --> D["04: Linking & Categories"] D --> E["05: Templates"] E --> F["06: Namespaces"] F --> G["07: Users & Permissions"] G --> H["08: Extensions"] H --> I["09: Maintenance"] I --> J["10: FAQ"] J --> K["11: Advanced Wikitext"] K:::current L["12: Image & Media"] M["13: Transclusion"] N["14: Parser Functions"] K --> L --> M --> N classDef current fill#38bdf8,color#0f172a,stroke-width:2px
Advanced Tables
Basic tables use {|, |-, |, and |}. Advanced tables add sorting, spanning, and styling.
Sortable Tables
Add the sortable class to make any table sortable by column:
{| class="wikitable sortable"
|+ Software Versions
! Name !! Version !! Release Date !! Status
|-
| MediaWiki || 1.42 || 2025-12-01 || Stable
|-
| PHP || 8.2 || 2024-11-30 || Stable
|-
| MariaDB || 11.4 || 2025-06-15 || Stable
|-
| Python || 3.13 || 2026-03-01 || Beta
|}
Renders as a table where readers click any column header to sort ascending or descending. The sortable class adds clickable arrows to each header automatically.
Row and Column Spanning
Use rowspan and colspan to merge cells:
{| class="wikitable"
|+ Feature Comparison
! Feature !! Free !! Pro !! Enterprise
|-
| Users || 1 || colspan="2" | Unlimited
|-
| Storage || 5 GB || 50 GB || rowspan="2" | Unlimited
|-
| API Access || No || Yes
|}
The colspan="2" cell spans across Free and Pro columns. The rowspan="2" cell spans across 50 GB and Yes rows. This reduces repetition and makes tables more readable.
Styled Cells
Apply inline CSS to individual cells:
{| class="wikitable"
! Status !! Count
|-
| style="background#ffebee;color#b71c1c" | Failed || 3
|-
| style="background#e8f5e9;color#1b5e20" | Passed || 47
|}
Each cell can have its own background color, text color, font weight, or any CSS property. Use this sparingly — too many colors make tables harder to read.
Advanced Lists
MediaWiki supports three list types that can be nested to any depth.
Nested Bullet Lists
* Level 1
** Level 2
*** Level 3
** Another Level 2
* Back to Level 1
Each extra asterisk indents one level deeper. You can go as deep as you need, though four levels is usually the practical limit for readability.
Nested Numbered Lists
# Step 1: Install
## Step 1a: Download
## Step 1b: Extract
# Step 2: Configure
## Step 2a: Edit settings
### Step 2a-i: Database settings
### Step 2a-ii: Cache settings
## Step 2b: Run installer
Numbered lists renumber automatically at each level. If you insert a new step between 2 and 3, all subsequent steps renumber without manual intervention.
Mixed Lists
# Step 1: Prepare
* Download the package
* Verify checksum
# Step 2: Install
* Extract files
* Run setup
# Step 3: Verify
#* Check version
#* Test connection
A #* creates a bullet under a number. A *# creates a number under a bullet. This is useful for procedures that have sub-steps or notes.
Definition Lists
; MediaWiki
: The software that runs Wikipedia
: Free and open-source
; Wiki
: A collaborative website
: Anyone can edit
The semicolon defines the term. The colon defines the description. Multiple colons after one term create multiple definitions. This is ideal for glossaries and key-value displays.
Collapsible Sections
Collapsible sections hide content behind a clickable "Expand" link. This is essential for long pages with optional detail.
Basic Collapsible Table
{| class="wikitable mw-collapsible"
|+ Detailed Changelog (click to expand)
! Version !! Changes
|-
| 1.0 || Initial release
|-
| 1.1 || Bug fixes
|-
| 1.2 || Security patch
|}
Add mw-collapsible to any table. The table shows collapsed by default with an "Expand" link. Add mw-collapsed to start collapsed:
{| class="wikitable mw-collapsible mw-collapsed"
|+ Click to expand
| Hidden content here
|}
Collapsible Divs
Wrap any content in a collapsible div:
<div class="mw-collapsible mw-collapsed" style="border:1px solid #ccc;padding:10px;">
<div style="font-weight:bold;">Troubleshooting Steps (click to expand)</div>
<div class="mw-collapsible-content">
Step 1: Check the log file.<br>
Step 2: Restart the service.<br>
Step 3: Contact support if the issue persists.
</div>
</div>
The inner mw-collapsible-content div contains the hidden content. You can put any wikitext inside — tables, lists, images, even other collapsible sections (though nested collapsibles can be confusing for readers).
Magic Words
Magic words are special strings that MediaWiki recognizes and acts on. They control page behavior and insert dynamic information.
Behavior Switches
Behavior switches are magic words that change how a page is displayed:
__NOTOC__ Hides the table of contents
__FORCETOC__ Forces the table of contents to appear
__NOEDITSECTION__ Hides edit links next to sections
__NEWSECTIONLINK__ Adds a "+" tab to start a new section
__NONEWSECTIONLINK__ Removes the "+" tab
__NOGALLERY__ Shows file categories as lists instead of galleries
__HIDDENCAT__ Hides this category from users
__INDEX__ Allows search engines to index this page
__NOINDEX__ Prevents search engines from indexing this page
Place these anywhere on the page, usually at the top or bottom. Each one is a double-underscore word that MediaWiki intercepts during rendering.
Variables
Variables display information about the current page or wiki:
{{CURRENTYEAR}} 2026
{{CURRENTMONTH}} 06
{{CURRENTMONTHNAME}} June
{{CURRENTDAY}} 28
{{CURRENTTIME}} 14:30
{{SITENAME}} My Wiki
{{PAGENAME}} Advanced Wikitext
{{NAMESPACE}} (empty for main namespace)
{{FULLPAGENAME}} Advanced Wikitext
{{REVISIONID}} 12345
{{REVISIONUSER}} Admin
These are useful in templates. For example, a "Last updated" notice can use {{REVISIONUSER}} and {{CURRENTDAY}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}} to show who last edited the page and when.
Page Name Manipulation
{{BASEPAGENAME}} Returns the page without subpage (e.g., "Advanced" from "Advanced/Wikitext")
{{SUBPAGENAME}} Returns the subpage name (e.g., "Wikitext" from "Advanced/Wikitext")
{{ROOTPAGENAME}} Returns the top-level page name
These are essential for breadcrumb navigation in subpage structures. A template can use {{BASEPAGENAME}} to generate a "Back to parent page" link automatically.
Putting It Together: A Documentation Page
Let's combine all techniques into one page. Create a page called "API Documentation" with:
__NOINDEX__
= API Documentation =
== Endpoints ==
{| class="wikitable sortable"
! Endpoint !! Method !! Version !! Status
|-
| /api/v1/users || GET || 1.0 || Stable
|-
| /api/v2/users || GET || 2.0 || Beta
|-
| /api/v1/posts || GET || 1.0 || Deprecated
|-
| /api/v2/posts || GET || 2.0 || Stable
|-
| /api/v2/posts || POST || 2.0 || Stable
|}
== Changelog ==
<div class="mw-collapsible mw-collapsed">
<div style="font-weight:bold;">View full changelog</div>
<div class="mw-collapsible-content">
=== Version 2.0 ===
* Added /api/v2/ endpoints
* Deprecated /api/v1/posts GET
* Fixed pagination bug
=== Version 1.0 ===
* Initial API release
* Basic CRUD operations
</div>
</div>
== Related Pages ==
; API Reference
: Full parameter documentation
; SDK Guide
: Client library usage examples
; FAQ
: Common troubleshooting questions
''Last updated by {{REVISIONUSER}} on {{CURRENTDAY}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}}.''
This page uses six advanced wikitext features: __NOINDEX__ magic word, sortable table, collapsible div, definition list, revision variable, and date variables. The result is a professional, dynamic documentation page.
What You Learned
- Sortable tables let readers reorder data by clicking column headers
- Rowspan and colspan merge table cells to reduce repetition
- Nested lists, mixed lists, and definition lists structure complex information
- Collapsible sections keep long pages manageable
- Magic words control page behavior and insert dynamic content
In the next lesson, you'll learn how to upload and manage images and media files on your wiki.
Common Mistakes
| Mistake | Why It Happens | How to Fix |
|---|---|---|
| Table not sorting | Missing sortable class |
Add class="wikitable sortable" to the table opening tag. Without sortable, headers are not clickable. |
| Collapsible section not working | Missing mw-collapsible class |
Every collapsible element must have the mw-collapsible CSS class. The mw-collapsed class is optional for starting collapsed. |
| Magic word shows as text | Wrong syntax or location | Magic words use double underscores (__NOTOC__) or double curly braces ({{CURRENTYEAR}}). Place behavior switches on their own line. |
| Nested list breaks | Mixed indentation | Use consistent prefix characters. A # after * requires no space: *# item. Any space between them creates a new list. |
| Definition list displays incorrectly | Extra blank lines | Definition lists require the term and description on consecutive lines. A blank line between ; Term and : Description breaks the pairing. |
{{PAGENAME}} returns wrong name |
Page move without update | {{PAGENAME}} always reflects the current page title. If you move the page, the magic word updates automatically. |
| Table cell spans too far | Wrong rowspan or colspan value |
Count the actual cells in each row. A rowspan="3" cell occupies space in three rows, so those rows need one fewer cell each. |
Practice Questions
- What CSS class makes a table sortable, and how does the sort behavior work with different data types like dates?
- How would you create a collapsible section that starts expanded but has a collapsible subsection inside it?
- Write the magic word combination to display "This page was last edited by {{username}} on {{date}}" using variables.
- Challenge: Create a single page that includes a sortable table with rowspan spanning, a collapsible FAQ section with 5 questions, a definition list of 3 terms, and a footer using
__NOINDEX__and{{REVISIONUSER}}. The page should be formatted as a product documentation page for an imaginary software tool called "DodaSync."
FAQ
Mini Project
Goal: Create a comprehensive product comparison page using all advanced wikitext techniques.
- Create a page called "DodaTech Tools Comparison"
- Add a sortable table with columns: Tool Name, Category, Price, Platform, Rating
- Include at least 6 tools (Doda Browser, DodaZIP, Durga Antivirus Pro, DodaSync, DodaBackup, DodaAnalytics)
- Use
rowspanto group tools by category (Browsers, Utilities, Security) - Add a collapsible "Detailed Specifications" section below the table
- Add a definition list of 3 key terms
- Use
__NOTOC__and display the current date with{{CURRENTDAY}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}} - Verify the table sorts correctly by clicking each column header
What's Next
Now that you've mastered wikitext, your pages will look professional. But text alone is not enough — you need images, diagrams, and media to make your wiki engaging.
Continue to Lesson 12: Image & Media — learn how to upload files, create galleries, and manage media settings.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro