Knowledgebase

How to check the ID number of a namespace in MediaWiki

The pages of a MediaWiki site are grouped into namespaces, so each page belongs to a namespace. Every namespace has an ID number and a text constant with which it's defined. If for some reason you need to know what the constant or ID number of a namespace is (e.g. when making changes to namespace options), there are a few ways you can check those.

  • An easy way to view the ID number of a namespace from the frontend of the site is with the magic word {{NAMESPACENUMBER}}. You can use that for any namespace, whether is a default preconfigured one or a custom one.

    First open a page that belongs to the particular namespace. You can view a list of all the pages in each namespace by going to Tools menu>Special Pages button>Lists of pages section>All pages button. On the page that opens there's a drop-down menu from which you can select for which namespace you want to see the pages. After you open a page from the namespace, edit it and in its content put {{NAMESPACENUMBER}}. After you save the change you'll see the ID number of the namespace to which the page belongs in the content of the page where you placed the magic word. After you're done you may want to edit the page again and remove the magic word, or otherwise the ID number will be left in the content.

  • The ID numbers and constants of the default namespaces that come preconfigured with MediaWiki are defined in the file Defines.php. It's in the includes folder; the folder is located in the root MediaWiki directory on your MediaWiki hosting account. Administrators who have access to the hosting account can check the ID numbers of the default namespaces there. To make matters easier you can also check them in the article with the reference list of MediaWiki namespaces with ID numbers and constants.

  • Custom namespaces are added and defined in the LocalSettings.php file; it's in the root folder of the MediaWiki hosting account. So if the namespace is a custom one, you can also check its ID number and constant there.

You may also find useful the following articles in our knowledge base related to namespaces:

Was this answer helpful?

 Print this Article

Also Read