Introduction to Semantic MediaWiki
What is Semantic MediaWiki?
Semantic MediaWiki (SMW) is a powerful MediaWiki extension that lets you turn a regular wiki into a collaborative knowledge base. By adding simple #set and #ask markup, you can store structured data (properties and values) directly on wiki pages and query that data across the whole wiki.
Key Concepts
- Properties: Named attributes (e.g.,
Has author,Published on) that describe a page. - Values: The data attached to a property – can be strings, numbers, dates, coordinates, etc.
- Queries: Inline queries using
#askor the special pageSpecial:Askto retrieve pages that match certain criteria. - Concepts: Saved query definitions that can be reused like virtual categories.
Why Use SMW?
SMW turns a wiki into a lightweight database without needing a separate DBMS. It enables:
- Dynamic tables, charts, maps, and timelines (via Semantic Result Formats).
- Faceted browsing with Semantic Drilldown.
- Complex compound queries (Semantic Compound Queries).
- Integration with forms (Page Forms) for easy data entry.
Installation Overview
# Using Composer (recommended)
composer require mediawiki/semantic-media-wiki
# In LocalSettings.php
wfLoadExtension( 'SemanticMediaWiki' );
# Run the update script
php maintenance/update.php --quickSMW requires MediaWiki 1.43+ and PHP 8.1+. No database schema changes are needed beyond the tables created by the update script.
Essential Configuration
$smwgEnableInlineQueries = true; // Allow #ask in page content
$smwgNamespacesWithSemanticLinks[NS_MAIN] = true; // Enable semantics on the main namespace
$smwgAutoRefreshOnPurge = true; // Refresh query results when a page is purgedThese settings are a good starting point; most wikis keep the defaults.
Typical Use‑Case Walkthrough
Visualise on a map (requires the Maps extension):
{{#ask: [[Category:Place]]
|?Has coordinates
|format=leaflet}}Query the data with an inline ask:
{{#ask: [[Category:Book]]
|?Has author
|?Published on
|format=table}}This renders a live table of all books with their authors and dates.
Create a property on a wiki page:
[[Has author::J. Doe]]
[[Published on::+2023-05-12]]
[[Has ISBN::978‑3‑16‑148410‑0]]Related Extensions Worth Exploring
- Semantic Result Formats – additional output formats (charts, calendars, etc.).
- Semantic Drilldown – faceted navigation.
- Semantic Compound Queries – combine several queries into one view.
- Page Forms – generate forms for data entry.
- Semantic Watchlist – watch changes to specific properties.
Getting Help
The official documentation lives on the SMW wiki (semantic-mediawiki.org). For community support, use the semwiki-user mailing list and the talk page on mediawiki.org.
This post is a draft – feel free to expand sections, add screenshots, or link to real‑world examples.