If I’m looking for a namespace number, I go to Special:AllPages (that link will take you to Wikipedia), pick the namespace in question from the dropdown, and then check the URL. For example, on Wikipedia, the URL for the
Portal namespace ends in
&namespace=100, so the namespace number is 100.
A faster-to-access but less user-friendly and more-overhead (you have to bookmark it instead of just searching for Special:AllPages each time) option is to use the API result:
Then you can Ctrl+F the name of the namespace you want and find the number.
Remove the need to know the number
You could also preclude the need to know the namespace number in some situations by writing a bookmarklet (or copying mine).
That bookmarklet of course is for
Special:AllPages itself, but you could write it to generalize to other situations in which you need to know the number such as accessing some system messages like edit notices.
Similarly, mwcleric has a namespace object which allows me to fetch all namespaces at the start of a session so that I can access them by name or number any time I need to use one.
If you have your own client library, I highly encourage doing similar.
I’m pretty serious about this one. Offhand I can tell you 0 is main, 2 is user, 8 is MediaWiki, 10 is template, and 828 is Module. I don’t often need to know others, though Form and Widget do come up and I don’t know them. The bigger issue is the over-a-dozen custom namespaces that I have, all with consecutive numbers over 10000. Those I can’t keep straight at all.
Why do you need to know namespace number so much?
- Editing system messages such as edit notices
- This is my preferred way for system messages to be configured. Header Footer does it based on namespace name, which seems like it’s more convenient because you don’t have to look up the number, but in practice it’s worse (imo) because I can’t pre-create the header-footer system messages for my next 10 custom namespaces a year in advance, the way I can for my edit notices. Though having a default/fallback wiki-wide header-footer to use would solve this problem…maybe I should write a PR…. Okay, I wrote a PR a couple days after writing a draft of this post, before publishing it.
- Accessing Special:AllPages itself, of course
- Immediately restricting search, recent changes, or contributions, without first having to click through the UI - of course, first clicking through the UI of another page somewhat defeats the purpose, this is where bookmarklets and/or “memorize them” (along with bookmarklets that just have a
%swhere I type a number) come into play
- It’s nice to have some keyword bookmarks that link directly to already-restricted searches in some cases
- Configuring some local settings such as
- Editing abuse filters
- CSS selectors - for example, to skin all
pres in the Module namespace, you would
I’m sure there’s tons of others - it comes up quite a bit. Any time you find yourself annoyed with not knowing the number of a namespace, see if you can throw together some tooling to make that situation a bit nicer for yourself! Or just keep clicking Special:AllPages. :)