Using Custom CSS in MediaWiki from Version 1.35 and newer
brief, General, Linux
In newer MediaWiki versions (1.35+), the process for adding custom CSS has changed from older versions.
There are now several options to use custom css styles for MediaWiki, below I want to show how to use your own custom stylesheet file by adding a new line in the LocalSettings.php configuration file which refers to your own created custom css file.
In your LocalSettings.php, add:
$wgHooks['BeforePageDisplay'][] = function( OutputPage $out, Skin $skin ) { $out->addStyle( '//example.com/path/to/your/styles.css' ); return true; };
In case you will not see the new styles applied immediately, we can append the following to our URL.
?action=purge
Links
MediaWiki
https://www.mediawiki.org/wiki/MediaWikiManual:LocalSettings.php
https://www.mediawiki.org/wiki/Manual:LocalSettings.php