Introduction to MediaWiki Extensions
- Daniel Scherzer
- Feb 12, 2023
- 4 min read
Updated: Feb 12, 2023
If you are considering adopting the MediaWiki software, odds are you have seen it before, at the very least because it is used on Wikipedia and other Wikimedia Foundation wikis. However, what you may not realize is that the software powering Wikipedia is not just “core” MediaWiki. Instead, dozens of “extensions” are used to expand functionality and provide new features. Some of these extensions come bundled with the core software and just need to be enabled, while others are downloaded separately. In a prior blog post, we identified what we think are the best MediaWiki extensions, but there are many great extensions, and we wanted to explain generally how extensions work.
The MediaWiki software is designed to be extended, and extensions have multiple points to connect with the core software to add new features. These include pages with custom content types, new page actions, special pages for non-page-specific functionality, and a way to add new wikitext components, among many other entry points.
MediaWiki Content Types
The most common type of page on a wiki uses “wikitext”, which supports headings, links, images, templates, and all the other features that make up a normal page. This is the default content model. Other types of content supported by MediaWiki core include JavaScript and CSS (for scripts and styles), JSON (for storing data), and “plain text”, which is just displayed as plain text.
Sometimes, a new feature requires a new type of content storage. For example, the Scribunto extension is used to allow embedding scripts in Lua. These scripts can then be run on pages directly, or via reusable templates. To store the scripts, Scribunto adds the aptly-named Scribunto content model.

If the snippet on the left was saved
with the title “Module:Test”, then
writing {{#invoke:Test|demo}}
would result in the text Hello,
world! being shown.
Another popular extension that adds a content type is TemplateStyles. Template Styles was designed to allow adding custom CSS styles to the output of individual templates, without needing to use the site-wide style sheets that get loaded on every page. To support custom validation of the styles, as well as restrictions such as rejecting background images from unknown sources, it uses a new sanitized-css content model.
MediaWiki Actions
Every request to a wiki includes a specific action to perform, even if the action is implicit. For example, the “view” action is assumed by default. Other actions that MediaWiki core provides allow for viewing page history, editing, and deleting a page or protecting it to restrict editing.
A key characteristic of an action type is the focus on a single page. For features dealing with multiple pages, see special pages below.
Actions can be used to both add new functionality and improve the defaults. For example, the PageForms extension, which is described in our prior blog post on the best extensions, adds a new way to edit pages. Another extension, AuthorProtect, allows page creators to protect their pages via the authorprotect action:

MediaWiki Special Pages
Unlike actions, special pages are primarily useful for features that deal with either multiple pages (like searching for pages with specific properties) or no page (like interacting with a user). MediaWiki core provides multiple pages for monitoring new changes. Special pages that do not deal with a page on the wiki include managing user rights or blocking accounts, version information for the code running on the wiki, and account creation/login.
A common anti-vandalism extension, Nuke, adds a special page to allow the deletion of multiple pages created by a single user. This comes bundled with MediaWiki.

Parser Tags and Functions
Sometimes, a new action, special page, or content type is simply overkill or not the right approach. Consider the case of adding new features to wikitext pages – instead of reimplementing the content type, MediaWiki’s parser allows extensions to register new tags (like <cite> from the Cite extension) or parser functions (such as the logical expressions in the ParserFunctions extension).
A fun new tag from the ImageMap extension, which comes bundled with MediaWiki core, is <imagemap>. This tag allows for custom hover text and link targets in different parts of the same image.

On the left, a copy of XKCD comic #285, depicting the character Cueball talking to a crowd, one of whom is holding a “citation needed” sign, is shown. Using the ImageMap extension and the wikitext snippet shown below, the overall image links to a general explanation of the comic, the drawing of Cueball links to an explanation of the character, and the “citation needed” sign links to the template on the English Wikipedia being referenced.

The file being displayed is used under the Creative Commons Attribution 2.5 Generic license and was retrieved from https://commons.wikimedia.org/wiki/File:Webcomic_xkcd_-_Wikipedian_protester.png.
Conclusion
In short, adding new page actions, types of content, or wikitext features is common and fairly simple. The MediaWiki software is specifically designed to be extensible, and in addition to the extensions that come with the core software, mediawiki.org lists over 1500 extensions at the moment. And, if the extension you are looking for isn’t available, WikiTeq can also create extensions for you!
Comments