Jump to content

Manual:Page naming

From mediawiki.org
This page contains changes which are not marked for translation.

A page name refers to the title of a page within the wiki. The title appears at the top of the page content. Within the MediaWiki site, the page names are used to identify and link to different pages.

Page names are also case-sensitive, except for the first letter, which is always capitalized by default.

For example: Manual:Page naming is different from Manual: Page nAming

A page name may contain two parts:

Namespace:Title

For example, this page exists in the Manual namespace .

In a URL, spaces are allowed in page names and are automatically converted to underscores (_). For example, "My Page" becomes "My_Page".

Magic words

[edit]

MediaWiki provides several magic words to handle and manipulate page names.

FULLPAGENAME

[edit]

Returns the title of the current page.

  • "{{FULLPAGENAME}}" → "Manual:Page naming" [1]

FULLPAGENAMEE

[edit]

Converts a page name to a form suitable for use in a URL by replacing spaces with underscores and encoding special characters.

  • "{{FULLPAGENAMEE:Manual:Newlines and spaces}}" → "Manual:Newlines_and_spaces" [2]

NAMESPACE

[edit]

Lists or extracts the namespace of a given page name.

  • "{{NAMESPACE}}" → "Manual" [3]
  • "{{NAMESPACE:Manual:Newlines and spaces}}" → "Manual" [4]

PAGENAME

[edit]

Removes the namespace from a given page name and renders the page's title only.

BASEPAGENAME

[edit]

Returns the base name of the page by removing the namespace and going up one level.

  • "{{BASEPAGENAME:User:A/b/c}}" → "A/b" [6]

SUBPAGENAME

[edit]

Returns the last part of the page name after the last slash.

  • "{{SUBPAGENAME:Help:Wikitext examples/transclusion demo}}" → "transclusion demo" [7]

SUBJECTPAGENAME

[edit]

Returns the namespace and title of the associated content page. This is similar to FULLPAGENAME.

  • "{{SUBJECTPAGENAME}}" → "Manual:Page naming" [8]

TALKPAGENAME

[edit]

Returns the namespace and title of the associated talk page.

  • "{{TALKPAGENAME}}" → "Manual talk:Page naming" [9]

A few things to note

[edit]

Invalid page names - If the provided page name is invalid, these magic words return an empty string.

  • "{{TALKPAGENAME:a[b}}" → "" [10]

Maximum length - The maximum length for a page name without the namespace is 255 bytes. Exceeding this will return an empty string.

  • "{{FULLPAGENAME:help:abcdefghijklmnopqrstuvwxyz...}}" → "Help:Abcdefghijklmnopqrstuvwxyz..." [11]

Interwiki prefixes - Some magic words behave differently if the input contains interwiki prefixes, which are not capitalized and handled according to the local settings of the wiki.

  • "{{FULLPAGENAME:ab:cdef}}" → "ab:cdef" [12]

Namespace with colon only - A namespace followed by a colon without a page name is not considered a valid page name and returns an empty string.

  • "{{FULLPAGENAME:help:}}" → "" [13]

These magic words help you manage and manipulate page names, making it easier to create dynamic and flexible wiki content.

Page title restrictions

[edit]

When creating page titles in MediaWiki, there are specific restrictions and special cases to be aware of. This guide simplifies these rules to help you avoid issues.

Special characters

[edit]

The following characters are not allowed in page titles (See Manual:$wgLegalTitleChars , deprecated):

 # < > [ ] | { }

Reasons for restrictions

[edit]

These characters are prohibited because they have special meanings in MediaWiki syntax.

For example:

[[tc]] links to a page titled Tc, not [[tc]].
{{tc}} refers to Template:Tc, not {{tc}}.

Testing page names

[edit]

You can test if a page name is allowed by trying to create a link to it:

[[a#b]] → a#b links to anchor b on page a
[[#b]] → #b links to anchor b on the current page
[[a|b]] → b piped link to page a
[[a%2f]] → a/ %2f is a slash, so page names cannot contain slashes
[[:/b]] → /b prefix with a colon to link
[[a_b]] → a_b underscore and space are equivalent, but the underscore is displayed
[[a b]] → a b no consecutive spaces in page names

Special cases

[edit]

Backslash (\):

May be converted to a forward slash (/) depending on context.

Forward slash (/):

It provides a special functionality in some namespaces.

To link to a page in the main namespace starting with /, use a colon: [[:/page]].

Namespace prefixes:

Page names cannot start with a generic namespace prefix. For example, an album titled Help: A Day in the Life in the English Wikipedia is called Help!: A Day in the Life to avoid being in help namespace.

Length limitations:

Maximum length: 255 bytes (excluding namespace prefix).

Non-ASCII characters may use up to 4 bytes each.

For example, this link tests the maximum page name length: 255 characters.

File namespace: 240 bytes for new uploads.

First Character Restrictions

Cannot be a colon (:), space ( ), or underscore (_).

Slashes (/) and percent signs (%) have special handling. For example, % followed by certain characters can cause issues (e.g., [[%23]] becomes #).

Understanding spaces vs. underscores in page names

[edit]

When naming pages, a space and an underscore function the same way:

  • Display - Spaces will appear as normal spaces in the title at the top of the page.
  • URL - In the page's URL, spaces will automatically be replaced by underscores.

For example:

  • Title display - "My Page Name"
  • URL - "My_Page_Name"

This means you don't need to worry about using spaces or underscores—they work interchangeably depending on where they appear.

Case-sensitivity in page names

[edit]

Namespace prefixes

[edit]
  • Case-insensitive - The characters in namespace prefixes (like "Help:", "User:", etc.) are not sensitive to case. This means "Help" and "help" are treated the same.
  • Canonical form - The system usually displays these prefixes with the first letter capitalized (e.g., "Help:") in URLs and page headers.

First character of the page name

[edit]
  • General rule - The first character of the page name (after the namespace prefix) is case-sensitive and will be auto-capitalized in MediaWiki.
  • Common practice - On most Wikimedia projects, the first character is case-insensitive. For example, "Help" and "Help" would link to the same page.

File name extensions

[edit]
  • Case-sensitive - The file name extensions for images (like .jpg or .JPG) are always case-sensitive.

This means Stop_sign_us.jpg and Stop_sign_us.JPG are considered two different files.

By understanding these rules, you'll be better equipped to manage and navigate pages accurately!

Handling spaces and underscores in page names

[edit]

When working with page names, it's important to know how spaces and underscores are treated.

Ignored spaces and underscores

[edit]

Certain spaces and underscores are automatically ignored or treated as equivalent:

Pattern Example
Before and after the page name [[ Help ]] → Help
Following a namespace prefix and before a colon [[Project :Help]] → Project :Help
After the colon of a namespace prefix [[Project: Help]] → Project: Help
Duplicate consecutive spaces [[Help:Talk page]] → Help:Talk page
[edit]

In some cases, spaces and underscores may still appear in the link labels even if they are ignored in the actual page link:

  • Example: [[___help__ :_ _template_ _]] is treated as Help:Template, but may display as ___help__ :_ _template_ _

Understanding URL encoding and page names

[edit]

When creating a page name, certain characters are automatically converted to their corresponding characters. This is known as URL encoding. For example:

  • %41 is the URL-encoded version of the letter A. So, if you try to name a page [[%41]], it will automatically be treated as A.
  • %C3%80 is the URL-encoded version of the letter À. Similarly, [[%C3%80]] will be treated as À.

In other words, even though you might try to use %41 or %C3%80 as page names, they will be converted to A and À, respectively. This means that pages with these names will not be distinct— %41 will always be the same as A, and %C3%80 will always be the same as À. For example, if you create a page named À, its URL might look like http://mediawiki.org/wiki/%C3%80, but the actual page name will be À.

Canonical form of page names

[edit]

When you reference a page using special tags, the system automatically formats the page name to a standard form called the "canonical form". Here's how it works:

  • Namespace Handling:
    • If there's a leading colon (like :PageName), it is removed.
    • The first letter of both the namespace (like Project:) and the page name is capitalized.
    • If a placeholder namespace is used, it is replaced with the actual one.
  • Formatting:
    • Underscores (_) are turned into spaces.
    • Multiple spaces in a row are reduced to a single space.

A few examples:

  • "{{:qwsazx}}" → "Qwsazx" [14]
  • help:example - When attempting to create this page, "h" and "e" are capitalized.

Alphabetical sorting in page names

[edit]

When organizing page names alphabetically, the system follows a specific order.

  • Basic order:
    • The system organizes page names based on the standard alphabetical order of characters. For example, looking at the Special:AllPages and Special:Categories pages, you can see that pages are sorted alphabetically.
  • Special characters:
    • Characters like punctuation marks and symbols come before letters. For example, !, @, and # appear before letters.
  • Unicode characters:
    • Characters from other languages and special symbols are sorted by their Unicode values. For example:
      • Uppercase letters (A-Z) come before lowercase letters (a-z).
      • Characters like à or é are placed based on their Unicode value, which might be after some lowercase letters.
  • Space characters:
    • A space in a page name is treated as an underscore (_). This means spaces are sorted after capital letters but before lowercase letters.

See also

[edit]