Help:Magic words

A magic word is a keyword or phrase recognized by the MediaWiki software (upon which Fandom is built) which triggers the software to do something special on the page. There are two types of magic words: those that are enclosed by double curly braces and those that are enclosed by double underscores (see below).

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 mw:Help:Extension:ParserFunctions.

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.



Instructions
It's generally best to add and edit magic words using a source editor.

To add a magic word, simply add the magic word to the content of the page somewhere. It will look like code in the editor, but after you save or preview, it will display as intended. Magic words will show up highlighted (in red for source editor, gray for visual editor).

In the Visual editor
In the VisualEditor, magic words that affect the page content will show as templates. Typing two opening curly braces will bring up a modal to "Add a template", which can be slightly confusing. Once the magic word is entered, and the Add template tab is clicked, there is an error message saying that "The "Template: " template doesn't yet exist." but using the Insert tab in the upper right corner of the modal will result in the magic word being added and it will function properly. See the example illustration of adding the  magic word to this page. Only magic words that are enclosed by double curly braces can be added this way in the Visual editor. You must use a Source editor to add the other type.

Common magic words
Here are some of the most commonly used magic words:
 * outputs the name of the page the word is placed on. ()
 * outputs the name of the community. ()
 * outputs the Contribution count of the community. ()
 * outputs the current day of the week. (Wednesday)
 * outputs the number of articles on your community. ()
 * outputs the full name of the page, i.e. with the namespace prefix, of the page it is placed on. ()
 * displays the ID (number) of the page's namespace. ()
 * hides the table of contents on a page.
 * places the table of contents exactly where this is entered. It overrides the NOTOC switch.
 * hides the "edit" links beside all headings on the page. To hide the edit link beside a particular heading, specify the heading using an HTML tag such as  rather than with the usual wiki equals-signs syntax.
 * replaces the "Edit" button with "Add topic", for adding new sections on a non-talk page.
 * replaces the "Add topic" button with "Edit", on talk namespaces.
 * placed on a category page, it makes the category hidden.
 * removes the category from Special:UnusedCategories which is helpful for tracking categories which should not necessarily appear as "unused" even when they are empty.

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.

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 1.19, they depend on the page content language.

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

For more thorough time formatting, you may want to install mw: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,  →  and   → ). Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example  and , or   and  ). Also applicable to  hereinbefore.

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

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

As of 1.15+, these can all take a parameter, allowing specification of the page to be operated on, instead of just the current page:

Page titles containing certain characters, such as apostrophes  or asterisks , may produce unexpected results when handled with these magic words, e.g.  . See bugs 14779, 16474 and 35628. One simple way to fix this is wrapping the pagename in #titleparts.

For example, if page name is "L'Aquila", the following code will produce the string "Numeric char encoding":

URL encoded page names
The following are equivalents encoded for use in MediaWiki URLs (i.e. spaces replaced with underscores and some characters HTML escaped using numeric character encoding):

Note that,   and   have distinct implementations. See mw: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 1.15+, 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:
 * →   (Empty)

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 ParserFunctions extension. For those see mw: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 is French,  is also valid, but   (the localisation of "File" in German) is not.

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

Don't confuse localised namespaces with custom namespaces.

Formatting
See also: mw: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, ,. More magic words are added by the Translate extension.

Transclusion modifiers
usually transcludes another page, by default from the Template:namespace.

These magic words modify that behavior.

Miscellaneous
{| class="wikitable plainlinks" !Usage !Output !Description !Version



Arabic
 * The full name of the language for the given language code: native name (language autonym) by default, name translated in target language if a target language code is specified. mw:Extension:CLDR must be installed for the translation to work.
 * 1.7+

1.18+ (translation)


 * The localized name for the given canonical Special: page.
 * 1.9+


 * The localized and URL-encoded name for the given canonical Special: page.
 * 1.20+
 * (Depends on parser tag)
 * Alias for XML-style MediaWiki parser tags or extension tags. It allows execution of wiki code and parser functions within tags before the tag is processed. It also prevents parsing of tags in conditional paths that aren't executed (like in  statements). Content between tags is passed as the first parameter, and any attributes for the tags can be passed as subsequent parameters. This example:
 * (Depends on parser tag)
 * Alias for XML-style MediaWiki parser tags or extension tags. It allows execution of wiki code and parser functions within tags before the tag is processed. It also prevents parsing of tags in conditional paths that aren't executed (like in  statements). Content between tags is passed as the first parameter, and any attributes for the tags can be passed as subsequent parameters. This example:

Your content goes here

…can be rewritten like this:

tagname Your content goes here attribute1=value1 attribute2=value2

Example for the Cite extension's  tags:

You must write tagname attribute1=value1 attribute2=value2  to pass an empty content. No space is permitted in the area reserved for content between the pipe characters  and   (similarly   and  ) may not always act inversely. For example:
 * &#x2192;
 * &#x2192;
 * &#x2192;

Further help and feedback
de:Hilfe:Zauberwörter es:Ayuda:Palabras mágicas fi:Ohje:Taikasanat fr:Aide:Mots magiques it:Aiuto:Parole magiche ja:ヘルプ:マジックワード ko:도움말:특수 변수 nl:Help:Magische woorden pl:Pomoc:Magiczne słowa ru:Справка:Волшебные слова tr:Yardım:Sihirli kelimeler uk:Довідка:Чарівні слова vi:Trợ giúp:Từ ma thuật zh:Help:魔术字