Example magic

Template:Wikipedia how-to

**Magic words** (including **parser functions**, **variables** and **behavior switches**) are features of wiki markup that give instructions to Wikipedia's underlying MediaWiki software. For example, magic words can suppress or position the table of contents, disable indexing by external search engines, and produce output dynamically based on the current page or on user-defined conditional logic. Some of these features are especially useful for templates.

This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation:

* mw:Help:Magic words: All standard magic words, including the "standard" parser functions.
* mw:Help:Extension:ParserFunctions: Additional parser functions, including conditional expressions.

## General information

In general, there are three types of magic words

1. **Behavior switches**: often appear in double underscores, all uppercase, *e.g.*, `__NOTOC__`. They will change the behavior of a page, rather than return a value.
2. **Parser functions**: all in lowercase. A parser function will be followed by colon and pipe-separated parameters, *e.g.*, `{{#ifexpr:Y|Yes|No}}`, wrapped in double braces. They will take a value and return a value.
3. **Variables**: these are all uppercase, e.g., `{{PAGENAME}}`. A variable will be wrapped in double braces and will return a value in its place.

The software generally interprets magic words in the following way.

* Magic words are case sensitive.
* White space is generously allowed for readability. It will be stripped from the start and end of their keywords and parameters (as is also done inside templates).
* They can be transcluded, even variables "about the current page". This is ensured by the parsing order.
* Instead of magically transforming into HTML instructions, `<nowiki>` tags remove this magic so a magic word can itself be displayed (documented).

{{Magic}} words compared to {{template}}:

* As with templates, magic words can be transcluded and substituted.
* The names of {{magic words}} are purposely chosen to be unlike the names of {{templates}}, and vice versa. Many parser function names will begin with the # sign, but template names  will not start with a # sign, and probably not end in a : colon character, or be all-uppercase.

## Variables

Shortcut:
* [[:]]

*Note:* The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon ( **:** ) is used to pass the parameter, rather than a pipe ( **|** ) that is used in templates, like `{{MAGICWORD:value}}`. For example, `{{TALKPAGENAME:Wikipedia:MOS}}` returns `Wikipedia talk:MOS` on any page. See meta:Help:Page name for more details of parser functions.

*Note:*
In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require prefixing a colon to avoid unwanted categorization.

### Other variables by type

Template:Startplainlist
* `{{CURRENTYEAR}}`
* `{{CURRENTMONTH}}`
* `{{CURRENTMONTHNAME}}`
* `{{CURRENTMONTHABBREV}}`
* `{{CURRENTDAY}}`
* `{{CURRENTDAY2}}`
* `{{CURRENTDOW}}`
* `{{CURRENTDAYNAME}}`
* `{{CURRENTTIME}}`
* `{{CURRENTHOUR}}`
* `{{CURRENTWEEK}}`
* `{{CURRENTTIMESTAMP}}`

Template:Endplainlist
Template:Startplainlist
* `{{LOCALYEAR}}`
* `{{LOCALMONTH}}`
* `{{LOCALMONTHNAME}}`
* `{{LOCALMONTHABBREV}}`
* `{{LOCALDAY}}`
* `{{LOCALDAY2}}`
* `{{LOCALDOW}}`
* `{{LOCALDAYNAME}}`
* `{{LOCALTIME}}`
* `{{LOCALHOUR}}`
* `{{LOCALWEEK}}`
* `{{LOCALTIMESTAMP}}`

Template:Endplainlist

* `{{REVISIONDAY}}`
* `{{REVISIONDAY2}}`
* `{{REVISIONMONTH}}`
* `{{REVISIONYEAR}}`
* `{{REVISIONTIMESTAMP}}`
* `{{REVISIONUSER}}c`
* `{{NUMBEROFARTICLES}}`
* `{{NUMBEROFFILES}}`
* `{{NUMBEROFEDITS}}`
* `{{NUMBEROFUSERS}}`
* `{{NUMBEROFADMINS}}`
* `{{NUMBEROFACTIVEUSERS}}`

Template:Endplainlist

a `{{REVISIONID}}` cannot be substituted and does not function in preview.
b English Wikipedia.
c This shows the last user to edit the page. There is no way to show the user viewing the page due to technical issues.
## Parser functions

Shortcut:
* [[:]]

### Metadata

 `{{NUMBERINGROUP:*groupname*}}` | Number of users in the usergroup named *groupname*.

To output numbers without comma separators (for example, as "123456789" rather than "123,456,789"), append the parameter `|R`.

### Formatting

  `{{padleft:*xyz*Template:Pipe*stringlength*}}  {{padright:*xyz*Template:Pipe*stringlength*}}
  `{{#time:*format*Template:Pipe*object*}}`   `{{#timel:*format*Template:Pipe*object*}}

### Paths

  `[[mw:Help:Extension:ParserFunctions##titleparts|{{#titleparts:*fullpagename*Template:Pipe*number*Template:Pipe*first segment*}}]]` | Splits the fullpagename (title) into that number of segments.

### Conditional

  `[[mw:Help:Extension:Parser functions##switch|{{#switch:*string* Template:Pipe*c1*=*r1* Template:Pipe*c2*=*r2* ... Template:Pipe*default*}}]]`  | Outputs *r1* if *string* is *c1*, *r2* if *string* is *c2*, etc., otherwise outputs *default* (if provided).

If, in these conditional functions, empty unnamed parameters are to be parsed as empty rather than as text (i.e. as empty rather than as the text "{{{1}}}", "{{{2}}}", etc.), they will require trailing pipes (i.e. `{{{1Template:Pipe}}}`, `{{{2Template:Pipe}}}`, etc., rather than `{{{1}}}`, `{{{2}}}`, etc.).

* For the use of these functions in tables, see Wikipedia:Conditional tables.

## See also

* Help:Magic links - for ISBN, PMID and RFC
* mw:Localisation
* mw:Manual:Extending wiki markup
* CoreParserFunctions.php
* wikEd, a MediaWiki editor with syntax highlighting for templates and parser functions
* Preferences → Gadgets → Editing → check Syntax highlighter
* Preferences → Beta features → check Wiki syntax highlighting
* Special:Version, at the bottom of the page, all the `{{magic words}}` on this page are listed there as Parser function hooks

Template:Wikipedia technical help

he:עזרה:משתנים