Jump to navigation Jump to search

On this page I collect useful stuff for running great MediaWiki websites :)
(This page is ever-growing)

MediaWiki Docu[edit]

Stying up-to-date / Newsletters:

Running a MediaWiki site[edit]

MediaWiki Support[edit]

Here you can get free support for MediaWiki:

Finding MediaWiki Consultants:


Short URLs[edit]

  • very important!
  • Docu: Short URL
  • What I use in my .htaccess files:
RewriteRule ^wiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ /mediawiki/index.php [L,QSA]
RewriteRule ^/*$ /mediawiki/index.php [L,QSA]
Last line redirects to
  • Not tested yet, but looks helpful to setup short URLs for MediaWiki:
  • Related to URL: If you set your wiki to private and you're not logged in, the homepage won't be redirected to but stay at This is useful for testing the pagespeed at

URLs with / without capitals[edit]

Default behavior:

  • URLs are case sensitive
  • However, the first character of the page name is case-insensitive - Example: redirects to (this is also the case on Wikimedia projects)
  • gives an error (also - this might be a problem if a user enters the URL this way (without capitals)

One can change behavior of links and allowed URLs with $wgCapitalLinks. Setting $wgCapitalLinks to false...

  • ...doesn't change anything about the existing pages with capitals!
  • ....enables links like small (which would link to a page "small" not "Small")
  • ...enable pages/URLs that start with a small letter

I still don't know if URLs with capitals are a bad thing in terms of SEO. If someone knows more about it please mail me at info AT


Possibilities to generate a sitemap:

Debugging & Hacking[edit]

If you get an empty page, chances are there is a fatal PHP error: Add this to the second line from the top (right below the <?php) of LocalSettings.php to turn on error messages:

error_reporting( -1 );
ini_set( 'display_errors', 1 );

This corresponds to

error_reporting = E_ALL
display_errors = On

in your php.ini.

For more info see Manual:How to debug. Another proposed way: [3]

My debugging "setup":

  • in my php.ini I had (and have) :
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
  • If my website is live I don't have any "debugging lines". If I want to debug something I temporarily add this code to my LocalSettings.php:
error_reporting( -1 );
ini_set( 'display_errors', 1 );
$wgShowExceptionDetails = true; 
$wgDebugLogFile = "/tmp/debug-{$wgDBname}.log";

Become a MediaWiki hacker:


  • Never go for windows hosting for Meadiawiki.[2]

Memory limit:

  • "The minimum amount of memory that MediaWiki "needs" is 50 megabyte."[3]
  • "The minimal limit should be something like 20 MB, but if you want MediaWiki to work correctly, consider using at least 50 MB."[4]

PHP Version:

Speeding up MediaWiki:

  • Manual:Performance tuning
  • $wgDBserver: Use IP addresses where possible to avoid the overhead of a DNS lookup for every single connection to the wiki.


  • If you have root or sudo access:
    • chown everything to the apache user/group (recursively). In Ubuntu: chown -R www-data:www-data your-mediawiki-directory
    • chmod LocalSettings.php to 600. Leaving everything else as default should be fine (644 for files and 755 for directories).
  • If you do not have root or sudo access:
    • chown LocalSettings.php and the images directory (recursively) so it is in your name but the apache group
    • chmod LocalSettings.php to 640 and chmod the images directory to 775 (recursively). Leaving everything else as the default should be fine.


Upgrading / Updating[edit]

Web updater:

  • Useful if you don't have SSH access. Instead of the update script you can use the web updater.
  • Accessible at
  • Manual:Upgrading#Web_updater
  • This is not recommended since the web update can timeout (see [4])

Essential changes (to me):

Major upgrades[edit]

This is how I do major upgrades on my wikis:

  1. Backup all MediaWiki databases and all FTP files that I adapted (for example these files).
  2. Access the command line by connecting to my server via Putty/SSH.
  3. Navigate to my website folder (not the mediawiki folder but the one that contains the mediawiki folder).
  4. Download the new package via wget (URLs of the download packages can be retrieved from Download).
  5. Extract the file via tar -xvzf mediawiki-1.3x.y.tar.gz (this will create a new folder named mediawiki-1.3x.y)
  6. Copy all "old", adapted FTP files into the new mediawiki folder.
    This includes, but is not limited to:
    1. extensions that are not bundled with the tarball
    2. the images folder (for example with cp -r sitename/mediawiki/images/ sitename/mediawiki-1.3x.y/
    3. LocalSettings.php
    4. composer.local.json
    5. custom skins (or changes you made to default skins)
  7. In the release notes for the new version, see if any changes need to be made to LocalSettings.php.
  8. Rename the old mediawiki folder to mediawiki-old.
  9. Rename the new mediawiki-1.3x.y folder to mediawiki.
  10. Update any extensions if there are updates.
  11. Run the update script with php_cli maintenance/update.php --skip-external-dependencies.
  12. Check my wiki if all works like it should, for example
    1. Viewing pages
    2. Editing pages
    3. Uploading a file
    4. Visit Special:Version and check that the version shown is correctly and that my extensions are present.

Minor upgrades[edit]

This is how I do minor version upgrades:

  1. Backup all MediaWiki databases and all FTP files that I adapted (for example these files).
  2. Access the command line by connecting to my server via Putty/SSH.
  3. Navigate to my html folder.
  4. Download the new patch file via wget
  5. Extract the file via gunzip mediawiki-1.xx.x.patch.gz
  6. Navigate to the mediawiki folder of the wiki.
  7. Run patch -p1 --dry-run -i ../../mediawiki-1.xx.x.patch to check what will be patched.
  8. If all is fine, run patch -p1 -i ../../mediawiki-1.xx.x.patch
  9. Visit Special:Version and check that the version shown is correctly and that my extensions are present.
  10. Repeat the last 4 steps for every wiki.

Upgrading extensions[edit]

This is how I upgrade my extensions:

  1. Visit the extension page and get the download link of the new version (I always try to run the master version, even if I'm on the LTS version).
  2. Access the command line by connecting to my server via Putty/SSH.
  3. Navigate to my extension folder.
  4. Run wget COPIED-URL
  5. Rename the existing extension folder to EXTENSION-NAME-old
  6. Run tar -xzf GZ-FILE (this extracts the files into the folder EXTENSION-NAME.
  7. Visit Special:Version and check that the version number is updated.
  8. Check functionality that the extension provides.

Maintenance scripts[edit]

  • Manual:Maintenance scripts
  • Helpful after importing data into your wiki (fixes categories for example): Manual:rebuildall.php
  • if you get an PHP Notice like "Undefined index: SERVER_NAME in /yourfolder/mediawiki/includes/GlobalFunctions.php on line 1471" you can try this on the console[5]
php update.php 
If php update.php doesn't work, try php_cli update.php


  • one can also run it with php srv/directory/mediawiki/maintenance/runJobs.php
  • SMW recommends parameter --maxjobs 1000

Moving entire wiki[edit]

Steps to change the domain of the wiki:

  • Point the new domain to your FTP folder
  • In LocalSetting.php change the domain under $wgServer
  • Done :)


Object caching:

  • If you use $wgMainCacheType = CACHE_ACCEL; and you can't login afterwards, try to set $wgSessionCacheType = CACHE_DB;.[7]

Page caching:

  • See Manual:File_cache
  • To invalidate all cached html files, just edit LocalSettings.php (adding a space is enough).
  • If you edited a template that is used on all pages, logged-in users see the change (coming from the template), but logged-out users are still served the cached page. -> Invalidate all cached files to reflect the changes for everybody.


All Extensions:


  • Download extensions and see most popular ones: Special:ExtensionDistributor
  • Snippets - small pieces of code to provide additional functionality whether interactive, visual or both.
  • Cite: It's okay to use <ref name="foo"></ref> and define foo only later.
  • If the version number on Special:Version is not updated although you have the new files in place: Topic:Ubxbytoe9k5jqkug

Useful extensions[edit]

Show a list of users who have contributed to an article:

  • Extension:Contributors: used often, works after this and this hack, in includable version contributors are sorted by edits, but not linked and there is no number of edits -> managed to hack the code so that users are linked and number of edits are shown :)
  • Extension:Contribution_Credits: ordered by username, stable, used 6 times (works!), managed to remove certain usernames by hacking extension
  • Extension:Uniwiki_Authors: old, unordered list, hack to show only users who contributed certain number of bytes, according to Wikipiary: not used
  • Extension:PageBy: excludes bots and anons, ordered by edits?, very old, used 6 times (but couldn't see it on two of those wikis)
  • Extension:AuthorInfo: limit number of shown users, not used, code completely outdated
  • Extension:Semantic_Extra_Special_Properties: unordered, output as a property (I can adapt it via ask function)

Extensions that (in my eyes) could provide a good commenting service (as of 23.7.2016):

  • Extension:Comments - works good. Anons can comment too, but they can only leave a text (not their name, not their website).
  • Extension:PageDisqus - integrates the Disqus commenting service to every page, right after the content area
  • Extension:Widgets - with Facebook and Disqus widgets

Failed extensions[edit]

Extensions I tried and didn't find to be useful (so far).

Extension My purpose Issue Solution
Extension:Multi-Category_Search Find pages that are in certain categories (more than one) None Found Semantic MediaWiki which suits my needs far better :)
smw-searchprofile Combine full text search with semantic search Doesn't offer it Use Extension:SolrStore instead
Extension:UniversalSuggester Add function to toolbar to search for certain templates and pages Problem with (standard) toolbar in 1.19.2 - and: doesn't work with WikiEditor toolbar - also see Extension_talk:UniversalSuggester#Where_is_the_toolbar.3F_19440 TO DO: Customize WikiEditor

Hooking / Building custom extensions[edit]

Ways to add HTML output (in MediaWiki 1.19)[edit]

Don't quote me on that, I might be wrong / not completely right.

If OutputPage object ($output) is passed to function

  • Use &$out in function definition, like function myFunction (&$out).
  • Then use one of the following:
    • $out->addHTML('<div id="yeah">bla</div>');
    • $out->addHTML("<div id=\"yeah\">bla</div>");

If OutputPage object ($output) is not passed to function

  • Use: global $wgOut;
  • Then use one of the following:
    • $wgOut->addHTML('<div id="yeah">bla</div>');
    • $wgOut->addHTML("<div id=\"yeah\">bla</div>");
Get the title of a page[edit]
  • in VectorTemplate.php: $this->getSkin()->getTitle()
  • in LocalSettings.php: $out->getTitle() (at least this works within a function like this function MyFunction(&$out, &$skin) { ... }

Example: Adding og:image to the Main page of your wiki (and only on the Main page):

$wgHooks['BeforePageDisplay'][] ='MyFunction';
function MyFunction(&$out, &$skin) {

	$script= "";
	if ($out->getTitle() == "Main page" ) { 
		$script .= "<meta property='og:image' content='/your-logo.png'>";

	$out->addHeadItem("My script", $script);
	return true;



table.your_zebra_class > tbody > tr:nth-child(2n) > td {
    background-color: #F3F5F5;

Sidebar tricks[edit]

  • Highlight a sidebar entry:
#p-Name-Of-Sidebar-Entry h5 a {
    background-color: yellow;
  • Add picture before sidebar entry:
#n-Name-Of-Sidebar-Entry > a {
    background: url("") no-repeat scroll -1px 1px transparent;
    padding-left: 23px;
  • Show a certain entry (or a group of entries) only to a certain user group:
Add to your Common.css:
#n-Name-Of-Sidebar-Entry { 
    display: none;
Add to MediaWiki:Group-groupname.css (for example for bureaucrats: MediaWiki:Group-bureaucrat.css, more examples at Manual:User group CSS and Javascript) :
#n-Name-Of-Sidebar-Entry { 
    display: block !important;

Design & Skins[edit]


Mobile skinning:

Learn skinning:

Cool skins[edit]

My favorites:

Other skins:


Show content only to logged-in users[edit]

Ways to show content only to logged-in users and not to anons ("show" means "print on screen"):

Working solution: CSS
In MW 1.16.2 I used this code to load a custom CSS sheet (in my PHP skin file) - this code still works with 1.19.2:

global $wgUser;
if (!$wgUser->isLoggedIn()) {
    $out->addStyle( 'vector/anon.css', 'screen' );

Create a file "anon.css" (in the skins/vector directory) and add:

.noanon {
   display: none;

Then in your wikitext add the following class if you don't want to show content to anons (that means if you want to show content only to logged-in users):

bla bla (visible to everyone)
<div class="noanon">
Only visible to logged-in users

Working solution: Extension:UserFunctions
Use parser function {{#ifanon:then|else}}.

Possible solution: common.js (not working for me)

use something like <div class="anononly>your wikitext</div>; in MediaWiki:common.css add: .anononly { display: none; } 
and in MediaWiki:common.js add if ( !mw.user.isAnon() ) { $( '.anononly' ).removeClass( 'anononly' ); }

Tried it and failed - tried the example shown here and replaced isanon with anonymous (since I used 1.19.2) but still no message.

Possible solution: user group CSS
One can load a CSS file for certain user groups via Manual:User_group_CSS_and_Javascript - this works fine for all user groups except for anons (see this discussion).
User group CSS file seems to be case sensitive (I had to name the file MediaWiki:Group-Mitschreiber.css instead of MediaWiki:Group-mitschreiber.css to get it working).

Show content only to a certain group (in PHP files)[edit]

The following worked for me - I added this code in my skin PHP file:

global $wgUser;
if (in_array("YourUserGroupName", $wgUser->getEffectiveGroups())) {




  • Bulk upload is possible with Extension:UploadWizard
  • Uploading within the editor is possible with the VisualEditor
  • Fix issues with uploading files in MW 1.26.2: in Ubuntu chown everything to www-data: chown -R www-data:www-data mediawiki

Other technical stuff:

  • Renaming (a lot of) images with the API: /api.php?action=move&from=File:old.jpg&to=File:new.jpg&token=xxxx
  • Manual:Image_administration#Deletion_of_images
  • Images URLs: To use absolute URLs instead of relative URLs place the domain in the variable $wgScriptPath. This is useful if you embed the wiki content on another domain but want the images to be loaded from the original (wiki) URL.

JavaScript & jQuery[edit]


$wgHooks['BeforePageDisplay'][] ='MyFunction';
function MyFunction(&$out, &$skin) {
    $script = "<script type='text/javascript'>Your JavaScript code</script>";
    $out->addHeadItem("My script", $script);
    return true;

Loading JavaScript that is required for other modules:
Since MediaWiki 1.26 all of MediaWiki's JavaScript is loaded asynchronously. If one doesn't load the external code through the ResourceLoader and declare dependencies, you have no guarantee that jQuery (or anything else) will be available at the time you load your code.[11]
-> Possibilities:


  • jQuery has been introduced in MediaWiki core as of MediaWiki 1.16 and is loaded by default on every page as of 1.17 (see JavaScript). One doesn't find any "jquery" term within the source code of the page though.
  • Add jquery ready function to Mediawiki:Common.js: just write $(document).ready(function() { without script tags.
  • If you add $(document).ready(function() { to the wikitext of a page, you'll get an error. This is because the script is loaded before jQuery and mw scripts[12]. Instead, edit Common.js and insert this, adapting the page name and script path:
if (mw.config.get('wgPageName') == 'Your page') {
  • Also, if you add a script.js (that contains jQuery) somewhere in your php files, there might be an error "$ is not defined". If you load the script via Mediawiki:Common.js there is no problem.
  • The JavaScript from Common.js is loaded after the page load event, so document.write cannot be used there.[13]

Search / Replace[edit]

The Wikimedia Foundation uses CirrusSearch (ElasticSearch). More info:

"Usual" MediaWiki uses LuceneSearch:

  • "The search functionality can be considered to operate on whole words." -> You won't get the desired results if you enter only a part of a word :(
    Good workaround: Use the search function of Extension:Replace Text (without replacing anything, i.e. don't carry out the 2nd step, just do the 1st one). It also finds part of a word :)
  • See Help:Searching#How_it_works for more info

Other search engines:



  • Extension:ReplaceText works fine - in terms of Regex (regular expressions) only the following special characters are allowed: ( ) . * + ? [ ] | - ^ for example doesn't work
  • To use other (all) Regex commands, use Extension:MassEditRegex
  • Do not alter the database with offline tools like Notepad++, see Topic:Ubxsfo482b58tlop.
  • People also recommend to use Pywikibot to do replacements on the wiki.


  • If admin creates a user account (for someone else):
    Benutzerkonto anlegen = use PW that was entered before
    Per E-Mail = use random PW and mail it to new user
  • Account names (usernames) are case sensitive. Not allowed characters in usernames by default: @ and : (see Manual:$wgInvalidUsernameCharacters). Spaces are allowed.
  • Change email address of an user: [9]
  • Mass delete (spam) users: Possible with Extension:BlockAndNuke in combination with Extension:UserMerge - see this paragraph



  • To define a new group just use a line in LocalSettings.php with $wgGroupPermissions['Test-Gruppe']['right'] = true; (it's not necessary to create a page MediaWiki:Group-Test-Gruppe, but it's recommened - see here)
  • How to add bureaucrats to protection groups
  • To disable for everyone and also users that don't belong to a certain group "Test-Gruppe":
# Disable for everyone.
$wgGroupPermissions['*']['edit']              = false;
# IMPORTANT: Disable for users too: by default 'user' is allowed to edit, even if '*' is not.
$wgGroupPermissions['user']['edit']           = false;
# Allow for Test-Gruppe:
$wgGroupPermissions['Test-Gruppe']['edit'] = true;


Multilingual Wiki[edit]


  • To see all namespaces used on a wiki (with their numbers): use URL mediawiki/api.php?action=query&meta=siteinfo&siprop=namespaces
  • All namespaces used by MediaWiki itself and its extensions: Extension default namespaces

Custom namespaces:


  • Get the content part of a page via the API: api.php?page=Albert_Einstein&action=parse&format=json
  • Special:ApiSandbox
  • Other stuff: search for api on this page

Connecting WordPress with MediaWiki[edit]

Single Sign-On

Run MW and WP on the same domain (without subdomains)
Say you want your wiki to be located at and at the same time you want your WordPress pages to be at and - and: the homepage should be also a WordPress page.

This worked for me:

  • Install MediaWiki in folder root/mediawiki and WordPress in root/wordpress.
  • In WP Dashboard -> Settings -> General set the following:
  • Copy the index.php from root/wordpress to root/ and change the line require('./wp-blog-header.php'); to require('./wordpress/wp-blog-header.php'); (see also [13])
  • Now comes the magic: Copy the content of root/wordpress/.htaccess and generate the following .htaccess file in root/ :
# BEGIN MediaWiki
RewriteEngine On
# for Short Wiki URL:
RewriteRule ^wiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ /mediawiki/index.php [L,QSA]
# To redirect all users to access the site WITHOUT the www. prefix,
# ( will be redirected to
# adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]
#END MediaWiki

# Copy the content of root/wordpress/.htaccess and add it below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
  • Make sure that you do not add a line like the RewriteRule ^/*$ /mediawiki/index.php [L,QSA] since this would forward the homepage to your wiki (we don't want this since we want a WordPress homepage).
  • This tutorial assumes that you use Short URLs for your wiki - I use the following lines in my LocalSettings.php:
$wgScriptPath       = "/mediawiki";
$wgArticlePath = "/wiki/$1";  
$wgUsePathInfo = true;
  • You don't have to delete the original .htaccess file in root/wordpress/.htaccess.

Messages / Languages[edit]

  • If you want to see system messages in another language add ?uselang=language to the URL (for english use ?uselang=en for example)
  • You can find the message you want to change by adding ?uselang=qqx to the URL.
  • MediaWiki:Copyright is only shown if $wgRightsText is set to something else than "" (also works if one uses $wgRightsText = " "; but in this case an empty image is put into the footer)


Timezone issues:



  • Any list with more than 10 references will get the CSS class .mw-references-columns[15]. This can be used to show the references in columns.

Creating content[edit]

Some special wikitext:




  • If the source is in the Template namespace, just use the name itself, alone: {{Bla}}
  • If the source is in the Main article namespace, you must put a colon (:) in front of the name, thus: {{:Cat}}
  • If the source is in any other namespace (e.g., "User:Example"), you must use the full name, including the namespace, thus: {{User:Example}}
  • Noinclude, includeonly, onlyinclude:
    • noinclude: displayed only when the template page is being viewed directly; will not be included; useful for a description how to use the template and for [[Category: Template]]
    • includeonly: displayed only when the page is being included. Useful for adding all pages containing a given template to a category, but not the template itself.
    • onlyinclude: only text surrounded by "onlyinclude" markup should be transcluded onto another page. It often overrules the other include tags: If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is only the material within the "onlyinclude" tags which gets transcluded.
  • If you want to know on which pages you've included a certain other page (with {{:Page}}):
    Go the page, click on "What links here" and "Hide Links" and "Hide redirects". Then one can see the transclusions easily.

Discussions & Watch/Unwatch[edit]

Liquid Threads[edit]

Update: Extension:LiquidThreads (LQT) is no longer maintained and replaced by Flow

Old stuff (just for the record):

  • Namespaces that LQT adds: Extension_default_namespaces#LiquidThreads
  • How to prevent anons from using LiquidThreads
  • Header
    • If a LQT thread is started in a discussion page, the LQT header seems to be generated (red "Kopfbereich ergänzen" changes to "Bearbeiten Versionen Löschen")
    • If one adds LQT to a page, the Edit and Delete links at the top disappear. You can find them in the LQT header (Discussion).
  • There are 2 user preferences (see Manual:$wgDefaultUserOptions at the very end of the table):
    • lqt-watch-threads: Selbst erstellte oder von mir bearbeitete Themen beobachten (true by default)
    • lqtnotifytalk: Bei Antworten zu beobachteten Themen E-Mails senden (false by default)
  • Problems (with 2.0 alpha):
    • lqt-watch-threads works - but after replying to a thread you have to refresh the page (clear cache) to see "unwatch" instead of "watch" (if you start a new thread it works just fine).

Parser functions[edit]

| usual cells
| without if {{#if:{{{Foo|}}}|<br />
{{!}} cells that are shown 
{{!}} only if Foo is not empty


  • #timel is identical to #time, except that it uses the local time of the wiki (I didn't have to set $wgLocaltimezone, #timel gave the right time anyway).
  • Check if a date is in the past or not:{{#ifeq:{{#expr:{{#time:U|DATE}}>{{#time:U}}}}|0|In the past|In the future}}

Images & Files[edit]

  • Turn off link to image description page: |link= (see also Help:Images#Display_image.2C_turn_off_link)
  • Directly link to a PDF instead of its description page: use [[Media:Filename.pdf]] instead of [[File:Filename.pdf]]
  • Get path to file: {{filepath:File.pdf}} - see here
  • Licensing


TOC / Headlines[edit]




Other wiki software:

  • Open sourceL DokuWiki, PmWiki, Tiki, TiddlyWiki,
  • Confluence (proprietary application)
  • CMS that include some limited wiki functionality: for example Traction TeamPage, Microsoft SharePoint

Market share: