Anamespace is a collection of pages which have content with a similar purpose, i.e. pages where the intended use is the same. Namespaces can be thought of as partitions of different types of information within the same wiki, and keep "real" content separate fromuser profiles,help pages, etc.The namespaceprefix of a page forms part of the title of a page, separated with acolon (:
).
As said, pages exist within a namespace, and this can be distinguished using the namespace prefix of a page, which forms part of the title of a page, separated with a colon (:
).
For example:
Title | Namespace | Code |
---|---|---|
Foo | Main | 0 |
Template:Foo | Template | 10 |
Module:Foo | Module | 828 |
The "main namespace" does not have a prefix. Also, pages in the main namespace cannot have names starting with any of the existing namespaces prefixes followed by a colon.
Pages can bemoved between namespaces simply by changing the prefix part of their title.
Namespace prefixes can be translated, and aliases (helpful in shortcuts) can be configured for each (see$wgNamespaceAliases
).All namespaces also have a "canonical" prefix, which works on all wikis regardless of configuration.Aliases and canonical names can be used in links, when performing asearch, and in the page title with the help of the {{DISPLAYTITLE}}magic word.
Each namespace has a correspondingnamespace index. Within the database, the title is split into namespace index and text title, and this is used for storage in thepage.page_namespace
andpage.page_title
columns, among others.
Most namespaces have an associateddiscussion namespace (or "talk" namespace).All discussion namespaces have odd-integer indices, and the discussion namespace index for a specific namespace with indexn isn+1.The namespaces with even-integer indices aresubject namespaces (note that this is a distinct concept fromcontent namespaces).The subject-talk duality can be explored using the{{SUBJECTPAGENAME}}
and{{TALKPAGENAME}}
magic words.The<body>
tag of pages in talk namespaces has thens-talk
CSS class, which might be useful for styling.
MediaWiki ships with 18 built-in namespaces:
The full list is presented in the table below.
ID | Name | Purpose | Talk | |
---|---|---|---|---|
0 | (Main) | "Real" content articles.[1] | Talk | 1 |
2 | User | User pages.[2] | User talk | 3 |
4 | Project | Information about the wiki.[3] | Project talk | 5 |
6 | File | Media description pages | File talk | 7 |
8 | MediaWiki | Site interface customization[4] | MediaWiki talk | 9 |
10 | Template | Template pages | Template talk | 11 |
12 | Help | Help pages | Help talk | 13 |
14 | Category | Category description pages | Category talk | 15 |
-1 | Special | Holds special pages | N/A | |
-2 | Media | Alias for direct links to media files |
Each namespace also has a constant derived from its name, with all letters in uppercase, spaces replaced by underscores, and prefixed byNS_
.For example, the constant for the "User talk" namespace isNS_USER_TALK
.A complete list can be found inManual:Namespace constants.
$wgMetaNamespace
, which unless manually set otherwise, defaults to$wgSitename
.Extensions and site administrators can define additional namespaces to group additional classes of pages together.For a thorough overview, seeManual:Using custom namespaces.
Some namespaces, like Project and Help, only exist for convenience and do not have any extra functionality compared to the Main namespace.
Template namespace pages can betranscluded without namespace prefix.
User namespace pages are associated with user accounts or IP addresses. Changes touser talk pages generate an automatic message notification.
Pages in the"MediaWiki" namespace are used to override default messages inlanguage file and can only be edited by administrators or other users with theeditinterface permission.
File and Category pages have special functionality, as described inHelp:Managing files andHelp:Categories.Files can be moved by users with the "movefile" right.Category pages can be moved by users with the "move-categorypages" right.
All pages in discussion namespaces have a "post a comment" feature.