From Wikipedia, the free encyclopedia
Special markup for MediaWiki
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:
In general, there are three types of magic words.
__NOTOC__
. They will change the behavior of a page, rather than return a value.{{#ifexpr:Y|Yes|No}}
, wrapped in double braces. They will take a value and return a value.{{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:
<nowiki>
tags remove this magic so a magic word can itself be displayed (documented), e.g. <nowiki>{{#magic:}}</nowiki>
or {{#magic:<nowiki/>}}
.Magic words compared to templates:
#
(pound or hash), but template names will not start with a #
, and probably not end in a :
(colon), or be all-uppercase.{{#magic: p1 | p2 | p3}}
, the name is #magic
and it is followed by an unspaced :
and a required input parameter, p1
. With a template, p1
is optional and it is preceded by a |
(pipe) instead of a :
, e.g. {{template|p1}}
.Most magic words can be used in any needed locations on a page; see MOS:ORDER for guidance on where Wikipedia prefers to place some magic words that are behavior switches (examples: DEFAULTSORT and DISPLAYTITLE).
Behavior switches Variables"WP:VAR" redirects here. For policies and guidelines with WP:*VAR shortcuts, mostly about style matters, see
WP:VARS.
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.
Caution: Attempting to use (some) page name variables to create a wikilink to an image page, category page or interlanguage link will produce a different effect: this will respectively place the image on the page, add the page to the category, or create an interlanguage link at the edge of the page. To override this normal behavior, prefix the variable with a colon (:
); for example [[:{{FULLPAGENAME}}]].
For more details on parser functions that relate to page names and namespaces, see: meta:Help:Page name ยง Variables and parser functions.
Other variables by type Current date and time Universal time Local-website time Variable Output Variable Output {{CURRENTYEAR}} 2025 {{LOCALYEAR}} 2025 {{CURRENTMONTH}} 05 {{LOCALMONTH}} 05 {{CURRENTMONTHNAME}} May {{LOCALMONTHNAME}} May {{CURRENTMONTHABBREV}} May {{LOCALMONTHABBREV}} May {{CURRENTDAY}}[b] 10 {{LOCALDAY}}[b] 10 {{CURRENTDAY2}}[b] 10 {{LOCALDAY2}}[b] 10 {{CURRENTDOW}} 6 {{LOCALDOW}} 6 {{CURRENTDAYNAME}} Saturday {{LOCALDAYNAME}} Saturday {{CURRENTTIME}} 22:05 {{LOCALTIME}} 22:05 {{CURRENTHOUR}} 22 {{LOCALHOUR}} 22 {{CURRENTWEEK}} 19 {{LOCALWEEK}} 19 {{CURRENTTIMESTAMP}}[c] 20250510220532 {{LOCALTIMESTAMP}}[c] 20250510220532 Parser functions MetadataPage IDs can be associated with articles via wikilinks (i.e. Special:Redirect/page/3235121
goes to this page). To output numbers without comma separators (for example, as "123456789" rather than "123,456,789"), append the parameter |R.
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. {{{1|}}}, {{{2|}}}, etc., rather than {{{1}}}, {{{2}}}, etc.).
Magic words can sometimes behave weirdly when substituted or nested. It's possible to subst some magic words (so that the page stops being updated if the value of the word changes). Here are some examples of how this works:
See also{{#ifexist:}}
expression while allowing redirects to be identified and parsed differentlyRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3