Knowledgebase
How to set and change the favicon in MediaWiki
The favicon is an icon that's displayed at the top of the browser next to the name of the site. It can be a small image of your site's logo or any image you want. To set or change the favicon of your MediaWiki site you have to do a couple of things: upload the actual image on the hosting account and modify the LocalSettings.php file of your MediaWiki.
- First you have to upload the favicon on your MediaWiki hosting account. It can be in any folder of the application. It can be in the root folder or in a subfolder. Wherever you upload it the path to the favicon is then specified in the LocalSettings.php file.
Make sure that the file that's uploaded is named favicon.ico (.ico is the file extension). You can use a different name but favicon.ico is the standard name used for the favicon in MediaWiki. For better results when the image is displayed on the frontend you should also resize and/or crop the image before uploading it. Make it's square and with dimensions 16 x 16 pixels. If it's 32 x 32, that will work fine too.
For the purposes of our example let's assume that your MediaWiki is installed directly in the root web-accessible folder on your account. That's the public_html folder (which makes the frontend of the site accessible at yourdomain.com). We'll also assume that the favicon is uploaded in the root MediaWiki folder, which in this case is also the root web-accessible folder on the account.
There are a few ways you can upload images and other files on your hosting account. HostKnox customers can do that from the Files section of the Pixie control panel. Another way to do it is to use an FTP client.
- Once you have the favicon on your hosting account you have to specify the path to it in the LocalSettings.php file. That's done with the help of the variable $wgFavicon. Assuming that you uploaded the favicon in the root MediaWiki directory on the account (that's the folder with the index.php file) and the full name of the favicon file is favicon.ico, then you can add the following on a new line at the end of LocalSettings.php:
$wgFavicon = "$wgScriptPath/favicon.ico";
If the favicon is in another MediaWiki directory, you can either move it or just change the path in the above code. For example, if it's in the folder /resources/assets (that's two levels down from the root MediaWiki folder), then you can modify the line to $wgFavicon = "$wgScriptPath/resources/assets/favicon.ico";.
The variable $wgScriptPath that's in the line is equivalent to the root MediaWiki directory on the account. So you don't have to specify the full path to the favicon on the account but just the path in relation to the root MediaWiki folder (i.e. the folder in which MediaWiki is installed).
The LocalSettings.php file that you have to modify is also located in the root MediaWiki folder. HostKnox customers can edit files on the account with the File manager of the Pixie control panel. An alternative way of editing the file is to download it on your local computer, edit it with a text editor (e.g. Notepad ++), then upload it back overwriting the old file.
- After you set (or change) the favicon, in order to see the result on the frontend you may need to clear the browser cache and then refresh/reload a page on your site. If you don't know how to flush the cache of your browser you may find useful the article on how to clear your browser cache.
If you need information on how to change the logo check out the article on how to change the logo in MediaWiki.