Knowledgebase

How to remove the Search block, the Navigation and Tools menus and menu links in MediaWiki

In MediaWiki there are a couple of default menus that are displayed on every page of the site. Usually they are shown in the left column of the site, but this is skin-specific. Most often they are collectively referred to as the sidebar, or sometimes they are also referred to as the quickbar.

One of these menus is usually labeled Navigation and it contains the links Main page, Recent changes, Random page, Help. The other menu is labeled Tools and it has links such as What links here, Related changes, Special pages, etc. The Search block is also considered part of the sidebar; sometimes it's displayed at a different location on the site, but usually it's shown with these two menus.

In this article we'll go over how to hide any of these menus. We'll show you how to remove a whole menu or just some of the links in the menus. We'll review a couple of different methods for doing that:

MediaWiki:Sidebar

On your site there's a page called MediaWiki:Sidebar (e.g. yourdomain.com/index.php/MediaWiki:Sidebar). It can be used to customize the sidebar menus. In this article we'll not go into details about all the things you can do with that page. We'll concentrate on removing the menu links and whole menus that are managed with this page.

Changes made to MediaWiki:Sidebar are applied to all skins. Unlike the CSS method, this one is not skin-specific. MediaWiki:Sidebar affects all pages on the site (the CSS method can be used to apply changes per page, per namespace, or to the whole site).

Keep in mind that only users that have the editinterface user right are allowed to edit the page MediaWiki:Sidebar. By default, only admins/sysops have that right.

Note that when it comes to removing menus and menu links the things that you can do with MediaWiki:Sidebar are limited, especially in relation to the Tools menu. To make changes to the menus, you need to open MediaWiki:Sidebar and open its edit form as any regular page. You'll see its default content:

* navigation
** mainpage|mainpage-description
** recentchanges-url|recentchanges
** randompage-url|randompage
** helppage|help
* SEARCH
* TOOLBOX
* LANGUAGES

If you haven't edited the page so far, when you open it instead of an Edit button you'll see a button for creating the page. Simply click on it, make the change and save it.

In the content of the MediaWiki:Sidebar page each menu title is shown with a single asterisk *. Links in the menu are shown with two asterisks **. As you can see only the navigation menu has its links listed. TOOLBOX stands for the Tools menu and SEARCH for the Search block with the text field for performing searches. If there are other languages installed, there's also a menu for selecting a language.

  • To remove a link from the Navigation menu simply delete its corresponding entry in the list. For example, if you delete ** mainpage|mainpage-description this will remove the link Main page.

  • To hide the title of the Navigation menu, just delete it in MediaWiki:Sidebar. For example, if you delete navigation (you can leave the asterisk *), this will remove the label Navigation in the actual menu. It's also possible to change the name; simply type it after the asterisk. Note that some skins don't display the label by default, even though it's listed in MediaWiki:Sidebar (e.g. the Vector skin).

  • Since the Tools menu is dynamically generated it's not possible to change its links through the page MediaWiki:Sidebar (at least not without any further code modifications). Removing *TOOLBOX will not remove the menu, or at least this will not work with most skins.

  • The same is true for the Search block. Removing *SEARCH from MediaWiki:Sidebar will not remove the search field from the site.

MediaWiki:Sidebar can also be used to add more links to the sidebar, and to rearrange the menus. To do this just change the order in which the menus are listed in the content of MediaWiki:Sidebar.

Remove Menus and Menu Links with CSS Modifications

With simple CSS (Cascading Style Sheets) modifications you can hide any of the menus or menu links. You can hide them on all pages, only on specific pages, or on the pages from a particular namespace.

The basic form of the code for removing any element, whether a whole menu or a single link, is:

element { display: none; }

You have to replace element with the actual tag and/or ID of the menu or link that you want to remove. This ID depends on the skin. Many skins use the same IDs for the default sidebar menus, but some skins may use different ones. The modification will work for all skins that match the ID. As an example we'll use the skins that come prepackaged with MediaWiki: Vector, MonoBook, Modern, Cologne Blue. All of them use the same IDs.

You can make a CSS modification by adding it to the content of the page MediaWiki:Common.css on your site (e.g. yourdomain.com/index.php/MediaWiki:Common.css), or if you want to make sure it affects only a specific skin you can add it to the CSS page of that skin instead (e.g. MediaWiki:Vector.css for the Vector skin). For more information on this check out the article on how to make CSS modifications in MediaWiki. There you'll also find tips on how to find out what the ID of an element is in the skin that you use.

Now we'll go over how to remove the default menus and menu links on all pages, per namespace and per page. As we mentioned we'll use as examples the prepackaged skins. The suggested modifications will work with all of them. If a modification works only with a particular skin, we'll explicitly mention that.


Remove the Search Block, Tools and Navigation Menus and Menu Links on All Pages

#mw_portlets { display: none; } - works with the Modern skin. Removes all the menus in the left column (Navigation, Search block, Tools).

#quickbar { display: none; } - works with the skin Cologne Blue. Removes all the menus in the left column of the Cologne Blue skin. Note that besides the menus that are considered part of the sidebar (Navigation menu, Tools menu, Search block), in the left column of the Cologne Blue skin there are also other menus displayed. In this article we won't go over those menus. For information on the IDs of these other menus, you may find useful the article on how to change background colors in MediaWiki (check the section on the Cologne Blue skin). You can use the examples there; you only have to replace the part of the code for displaying the element (the one in the curly brackets).

Navigation Menu

#p-navigation { display: none; } - removes the whole Navigation menu.

#p-navigation h3 { display: none; } - removes only the label/title of the Navigation menu.

#n-mainpage-description { display: none; } - removes the Main Page link.

#n-recentchanges { display: none; } - hides the Recent changes link.

#n-randompage { display: none; } - removes the Random page link from the menu.

#n-help { display: none; } - removes the Help link.

Search Block

#p-search { display: none; } - removes the Search block. Usually it's displayed together with the two default menus. From the prepackaged skins only the Vector skin displays it at a different location, in the top right corner of the page. The Cologne Blue skin shows one Search field in the left column and one in the footer. This modification affects only the one in the left column.

#searchform-footer { display: none!important; } - this modification is only for the Cologne Blue skin. It removes the Search block that's displayed in the footer.

#p-search h3 { display: none; } - hides the label of the search block. The Vector skin doesn't display a label/title by default.

Tools Menu

Note that the default links that are displayed in the Tools menu depend on the page that is opened. For example, some links are displayed when a personal user page is viewed, but not when an article is opened.

#p-tb { display: none; } - removes the whole Tools menu.

#p-tb h3 { display: none; } - removes only the label of the Tools menu.

#feedlinks { display: none; } - hides the Atom link for the RSS feeds. This link is shown only when certain pages are viewed, such as the Recent changes page and the page Related changes.

#t-whatlinkshere { display: none; } - hides the link What links here.

#t-recentchangeslinked { display: none; } - removes the link Related changes.

#t-contributions { display: none; } - removes the link User contributions. This link is shown when the personal page of a user is viewed, and also on some other pages such as the page with the logs related to the user.

#t-log { display: none; } - removes the link Logs. This link is shown on the personal pages of users. The link opens the log that lists all the actions performed on the site by the user.

#t-blockip { display: none; } - hides the link Block user. The link is shown on the personal pages of users, and on some other pages. It opens the form for blocking users. The link is visible to those users who have the right to block users. By default, admins/sysops have that right.

#t-userrights { display: none; } - removes the link User rights management. This link is otherwise displayed on the personal pages of users, and on some other pages. It's visible to those users who belong to a group that has the right to assign users to user groups. By default, bureaucrats can do that. The link opens the form for adding and removing users to user groups.

#t-upload { display: none; } - removes the link Upload file. The link is only available if file uploads are enabled.

#t-specialpages { display: none; } - hides the Special pages link.

#t-print { display: none; } - removes the link Printable version.

#t-permalink { display: none; } - removes the link Permanent link.

#t-info { display: none; } - hides the link Page information.


Remove the Search Block, Tools and Navigation Menus and Menu Links per Namespace

With CSS modifications instead of removing a menu or menu links on all pages of the site you can also do this only for the pages belonging to a particular namespace. To do this you only have to add some more code in front of the code for removing the element on all pages. It will specify the namespace to which the modification will apply. For example:

.ns-0 #t-print { display: none; }

will remove the link Printable version (part of the Tools menu) from all pages that belong to the namespace with ID number 0. That's the Main namespace that contains the articles. For information on the default namespaces and their IDs check out the reference list of MediaWiki namespaces.


Remove the Search Block, Tools and Navigation Menus and Menu Links per Page

Another thing you can do is to remove menus and menu links only from particular pages. You only need to add in front of the code for removing the element on all pages some more code specifying the page to which it should be applied. For instance:

body.page-Example_Page #p-tb { display: none; }

will remove the Tools menu only from the page Example Page. If the title of the page consists of more than one word, separate words with underscores _. In case the page is from a namespace other than the Main namespace, you should also add the namespace prefix in front of the page title and separate them with an underscore (e.g. Talk_Example_Page).

Some other articles in our knowledge base with CSS modifications that you may find useful:

Was this answer helpful?

 Print this Article

Also Read