MediaWiki, the software powering Wikipedia, allows you to customize the appearance of your wiki site by using different skins and sections. It is open source and written PHP.
A skin is a collection of files that define the layout, colors, fonts, and images of your wiki site. There are several pre-built themes shared on internet and also custom skins can be added to your MediaWiki server.
In this article, we will show you how to add a (custom) skin to MediaWiki. The method shown below will work on any Linux-based distribution such as Ubuntu, CentOS, Red-Hat, etc.
Prerequisites
Before you start, you will need the following:
- A MediaWiki site installed and running on your server
- A custom skin that is compatible with your MediaWiki version
- A text editor to edit the configuration file
The first step is to extract or place your custom skin files where your MediaWiki site is. We have a skin sub-folder to place it there.
The skin folder is placed in the “skins” subdirectory, which is located in the root of your MediaWiki installation.
For example, if your MediaWiki site is installed in /var/www/html/wiki
, then skin files should be placed in /var/www/html/wiki/skins
.
unzip mySkin.zip -d /var/www/html/wiki/skins
This will create a directory, for custom skin, called “mySkin” in the /var/www/html/wiki/skins
directory.
Step 2: Edit the LocalSettings.php File
The LocalSettings.php contains all configurations for MediaWiki. It is located in the root of your MediaWiki installation. We need to configure it.
To edit the LocalSettings.php
file, use a command-line tool like nano or vim or any GUI tool. For example, you can edit it using nano with the following command:
nano /var/www/html/wiki/LocalSettings.php
This will open the LocalSettings.php file in nano.
Add the following code to the bottom of the LocalSettings.php file, replacing “SkinName” with the name of your custom skin:
wfLoadSkin( 'SkinName' );
$wgDefaultSkin = "SkinName";
This will load the custom skin and set it as the default.
Save and close the LocalSettings.php file by pressing Ctrl+X and then Y.
Step 3: Clear Cache and Check
The final step is to clear the cache with the following command:
php maintenance/update.php --quick
This will update database schema and clear any cached data.
Clear your browser cache as well by pressing Ctrl+F5 or Cmd+Shift+R.
Check your MediaWiki site by visiting http://127.0.0.1/wiki. You should see new skin applied to the wiki.
That's it! We hope you found this tutorial helpful and informative while setting up your site. Thank you for reading!