top of page

Introduction to MediaWiki Extensions

Updated: Feb 12

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.

Scribunto example

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: