Help:Magic words

Magic words are strings of text that MediaWiki associates with a return value or function, such as time, site details, or page names. This page is about usage of standard magic words; for a technical reference, see.

There are three general types of magic words:
 * Behavior switches: these are uppercase words surrounded by double underscores, e.g. __FOO__
 * Variables: these are uppercase words surrounded by double braces, e.g.  . As such, they look a lot like templates.
 * Parser functions: these take parameters and are either of the form   or  . See also.

Page-dependent magic words will affect or return data about the current page (by default), even if the word is added through a transcluded template or included system message.

Behavior switches
A behavior switch controls the layout or behavior of the page and can often be used to specify desired omissions and inclusions in the content.

{subst:| class="wikitable" ! | Word ! | Description ! | Versions ! colspan="3"| Table of contents ! colspan="3"| Editing ! colspan="3"| Categories ! colspan="3"| Language conversion ! colspan="3"| Other
 * Hides the table of contents (TOC).
 * Forces the table of contents to appear at its normal position (above the first header).
 * Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position.
 * Forces the table of contents to appear at its normal position (above the first header).
 * Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position.
 * Forces the table of contents to appear at its normal position (above the first header).
 * Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position.
 * Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position.
 * Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position.
 * Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position.
 * Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position.
 * Hides the section edit links beside headings.
 * Adds a link ("+" by default) beside the "edit" tab for adding a new section on a non-talk page (see ).
 * 1.7+
 * Removes the link beside the "edit" tab on pages in talk namespaces.
 * Adds a link ("+" by default) beside the "edit" tab for adding a new section on a non-talk page (see ).
 * 1.7+
 * Removes the link beside the "edit" tab on pages in talk namespaces.
 * 1.7+
 * Removes the link beside the "edit" tab on pages in talk namespaces.
 * Removes the link beside the "edit" tab on pages in talk namespaces.
 * Removes the link beside the "edit" tab on pages in talk namespaces.
 * Used on a category page, replaces thumbnails in the category view with normal links.
 * 1.7+
 * Used on a category page, hides the category from the lists of categories in its members and parent categories (there is an option in the user preferences to show them).
 * 1.13+
 * Used on a category page, hides the category from the lists of categories in its members and parent categories (there is an option in the user preferences to show them).
 * 1.13+
 * Used on a category page, hides the category from the lists of categories in its members and parent categories (there is an option in the user preferences to show them).
 * 1.13+
 * On wikis with language variants, don't perform any content language conversion (character and phase) in article display; for example, only show Chinese (zh) instead of variants like zh_cn, zh_tw, zh_sg, or zh_hk.
 * On wikis with language variants, don't perform language conversion on the title (all other content is converted).
 * No effect.
 * Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace. Removed in.
 * 1.1–1.8
 * Tell search engines to index the page (overrides, but not robots.txt).
 * 1.14+
 * Tell search engines not to index the page (ie, do not list in search engines' results).
 * On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title".
 * }
 * Tell search engines to index the page (overrides, but not robots.txt).
 * 1.14+
 * Tell search engines not to index the page (ie, do not list in search engines' results).
 * On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title".
 * }
 * Tell search engines not to index the page (ie, do not list in search engines' results).
 * On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title".
 * }
 * On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title".
 * }
 * On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title".
 * }
 * }

Variables
Variables return information about the current page, wiki, or date. Their syntax is similar to templates. Variables marked as " [expensive] " are tracked by the software, and the number that can be included on a page is limited.

If a template name conflicts with a variable, the variable will be used (so to transclude the template    :PAGENAME you would need to write  ). In some cases, adding parameters will force the parser to invoke a template; for example,  transcludes     :CURRENTDAYNAME, not the variable.

Date and time
The following variables return the current date and time in UTC.

Due to MediaWiki and browser caching, these variables frequently show when the page was cached rather than the current time.

The date and time magic words are formatted in the wiki content language. Since, they depend on the page content language.

The following variables do the same as the above, but using the site's server config or $wgLocaltimezone.


 * For more thorough time formatting, you may want to install Extension:ParserFunctions to use the #time parser function

Technical metadata
Note: Revision variables return data about the latest edit to the current page, even if viewing an older version of the page.

Statistics
Numbers returned by these variables normally contain separators (commas or spaces, depending on the local language), but can return raw numbers with the ":R" flag (for example,  &rarr;  and   &rarr; ). Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example  and  ). Also applicable to  above.

The number magic words are formatted in the wiki content language. Since, it depends on the page content language.

Page names
The  and   magic words only work in namespaces that have subpages enabled. See for information on enabling subpages.

URL encoded page names
The following are equivalents encoded for use in MediaWiki URLs (i.e. spaces replaced with underscores and some characters percent-encoded):

As of, these can all take a parameter, allowing specification of the page to be operated on, instead of just the current page:
 * &rarr; 

Note that,   and   have distinct implementations. See Manual:PAGENAMEE encoding for details.

Namespaces
The following are equivalents encoded for use in MediaWiki URLs (spaces replaced with underscores and some characters percent-encoded):

As of, these can take a full-page-name parameter and will return the requested namespace associated with that page, instead of with the current page: Parameter must not be a namespace name:
 * &rarr; 
 * &rarr; 
 * &rarr; 
 * &rarr; 

Parser functions
Parser functions are very similar to variables, but take one or more parameters (technically, any magic word that takes a parameter is a parser function), and the name is sometimes prefixed with a hash to distinguish them from templates.

This page only describes parser functions that are integral to the MediaWiki software. Other parser functions may be added by MediaWiki extensions such as the. For those see Help:Extension:ParserFunctions.

Namespaces
returns the current localized name for the namespace with that index, canonical name, or local alias. Thus,  , and   (an old name for the File namespace) all return "    ". On a wiki where the content language was French,  would also be valid, but   (the localisation of "File" into German) would not.

is the equivalent encoded for MediaWiki URLs. It does the same, but it replaces spaces with underscores, making it usable in external links.

Formatting
See also: Extension:StringFunctions

Localisation
Here are the magic words which are used as main localisation tools. Other magic words will often depend on the wiki's locale and configuration or on the chosen language: see in particular, ,.

The usage of these magic words can be very complex, and the documentation is currently incomplete; there's some more info on Plural, Grammar, Gender.