Manual:Namespace
A namespace 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 from user profiles, help pages, etc.
Contents |
[edit] Technical overview
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 |
---|---|
Foo | Main |
Project:Foo | Project |
Help:Foo | Help |
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 be moved between namespaces simply by changing the prefix part of their title.
Namespace prefixes can be translated, and aliases 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 a search, and in the page title with the help of the {{DISPLAYTITLE}} magic word.
Each namespace has a corresponding namespace index. Within the database, the title is split into namespace index and text title, and this is used for storage in the page.page_namespace and page.page_title columns, among others.
[edit] Subject and talk namespaces
- See Help:Talk pages for instructions on how to use talk pages.
Most namespaces have an associated discussion namespace (or "talk" namespace). All discussion namespaces have odd-integer indices, and the discussion namespace index for a specific namespace with index n is n+1. The namespaces with even-integer indices are subject namespaces (note that this is a distinct concept from content namespaces). The subject-talk duality can be explored using the {{SUBJECTPAGENAME}}
and {{TALKPAGENAME}}
magic words. The <body>
tag of pages in talk namespaces has the "ns-talk
" CSS class, which might be useful for styling.
[edit] Built-in namespaces
MediaWiki ships with 18 built-in namespaces.
The following 8 namespaces all have associated discussion namespaces.
Index | Name | Constant | Purpose | Comments |
---|---|---|---|---|
0 | Main | NS_MAIN | "Real" content; articles | Has no prefix |
1 | Talk | NS_TALK | Talk pages of "Real" content | |
2 | User | NS_USER | User pages | |
3 | User talk | NS_USER_TALK | Talk pages for User Pages | |
4 | Project | NS_PROJECT | Information about the wiki | Prefix is the same as $wgMetaNamespace[1] |
5 | Project talk | NS_PROJECT_TALK | ||
6 | File | NS_FILE | Media description pages | |
7 | File talk | NS_FILE_TALK | ||
8 | MediaWiki | NS_MEDIAWIKI | Site interface customisation | Protected by default. Only users with the 'editinterface' permission can edit pages in this namespace. |
9 | MediaWiki talk | NS_MEDIAWIKI_TALK | ||
10 | Template | NS_TEMPLATE | Template pages | |
11 | Template talk | NS_TEMPLATE_TALK | ||
12 | Help | NS_HELP | Help pages | |
13 | Help talk | NS_HELP_TALK | ||
14 | Category | NS_CATEGORY | Category description pages | |
15 | Category talk | NS_CATEGORY_TALK |
2 other namespaces have negative indexes and have special purposes. You cannot create or delete pages in these namespaces, and there are no corresponding discussion namespaces.
Index | Name | Constant | Purpose |
---|---|---|---|
-1 | Special | NS_SPECIAL | Holds special pages |
-2 | Media | NS_MEDIA | Alias for direct links to media files |
- ↑ Unless manually set, $wgMetaNamespace defaults to $wgSitename.
[edit] Custom namespaces
It is possible to define additional namespaces to group additional classes of pages together. This is done using the $wgExtraNamespaces configuration variable.
For a thorough overview, see Manual:Using custom namespaces.
[edit] Functionality
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 be transcluded without namespace prefix.
User namespace pages are associated with user accounts or IP addresses. Changes to user talk pages generate an automatic message notification.
Pages in "MediaWiki" namespace are used to override default messages in language file and can only be edited by administrators or other users with the editinterface permission.
File and Category pages have special functionality, as described in Help:Managing files and Help:Categories. Category pages cannot be moved (renamed) yet (but they can be exported and then imported, if you need to maintain edit history). Image moving can be enabled with $wgAllowImageMoving in MediaWiki 1.13 and above.
All pages in discussion namespaces have "post a comment" feature (see meta:Help:Section#Adding a section at the end).
[edit] See also
- Help:Namespaces
- Extension namespace registration
- Manual:Configuration settings#Namespaces
- Manual:Namespace constants
- meta:Help:Namespace
Language: | English • 日本語 • Polski • Русский • 中文 |
---|