Magic words (includingparser functions,variables, andbehavior switches) are features ofwiki markup that give instructions to Wikipedia's underlyingMediaWiki software. For example, certain magic words are used to suppress or position thetable of contents, disableindexing by external search engines, or produce output dynamically based on the current page or on user-definedconditional expressions. Some of these features are especially useful fortemplates.
This page is a quick reference for magic words. For more comprehensive information, refer to the main MediaWiki documentation:
mw:Help:Magic words: All standard magic words, including the "standard" parser functions.
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.
Parser functions: all in lowercase. A parser function sometimes starts with a pound sign (#) and will always be followed by a colon (:) and pipe-separated (|) parameters, e.g.,{{#ifexpr:Y|Yes|No}}, wrapped in double braces. They will take a value and return a value.
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:
White space is generously allowed for readability. It is stripped from the start and end of their keywords and parameters (as is also done in template calls using named parameters).
They can betranscluded, 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), e.g.<nowiki>{{#magic:}}</nowiki>or{{#magic:<nowiki/>}}.
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 a#(pound or hash), but template names will not start with a#, and probably not end in a: (colon), or be all-uppercase.
The first parameter's syntax differs. In{{#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 where needed on a page, but seeMOS:ORDER for guidance on placing some magic words that are behavior switches (such as{{DEFAULTSORT:}} and{{DISPLAYTITLE}}).
Places the page'stable of contents (TOC) at the word's position. This magic word does not work in skins that present the table of contents outside the article content e.g. the defaultVector 2022 skin.
__FORCETOC__
Forces the TOC to appear in its default position, even when there are fewer than four headings. Can be used anywhere on a page. This magic word does not work in skins that present the table of contents outside the article content e.g. the default Vector 2022 skin.
__NOTOC__
Suppresses the appearance of the page's TOC. Can be used anywhere on a page.Mobile version use an alternative navigation scheme, which is not affected by__NOTOC__.
Editing
__NOEDITSECTION__
Hides the "edit" links normally besideall headings on the page. To hide the edit link beside aparticular heading, specify the heading using e.g. anHTML tag such as<h2>heading</h2> rather than with the usual wiki equals-signs syntax (e.g.==heading ==).
If this switch is not intended to be transcluded with the template's contents, it should be used inside<noinclude>...</noinclude> (or on a template documentation page inside <noinclude>...</noinclude>), similarly to template categories.
If the switch is intended to remove from the report all pages that transclude a given template (for example, a notice that is transcluded on testcases or sandbox subpages), put the switch inside <includeonly>...</includeonly> tags within the template page.
Prevents the link on aredirection page from being updated automatically when the page to which it redirects is moved (and "Update any redirects that point to the original title" is selected).
Some pages do not fit the scope of Wikidata items, such as discussion archives, template subpages, etc. To prevent a page from being listed inSpecial:UnconnectedPages, use this magic word anywhere on the page. Pages that don't meetWikidata's notability criteria should not receive a Wikidata item (seemw:Extension:Wikibase).
(equivalent to{{NOEXTERNALLANGLINKS:*}}) Suppresses the automated inclusion ofWikidatainterlanguage links on the lefthand side of the page. To suppress specific language links rather than all languages use{{NOEXTERNALLANGLINKS:list}}, wherelist is apipe-delimited list ofISO 639‑1 language codes (e.g.{{NOEXTERNALLANGLINKS:fr|es|ja}} to suppress the French ("fr"), Spanish ("es") and Japanese ("ja") interlanguage links).
"WP:VAR" and "WP:PAGENAME" redirect here. For policies and guidelines with WP:*VAR shortcuts, mostly about style matters, seeWP:VARS. For the article naming policy, seeWikipedia:Article titles.
On a subpage, rightmost portion ofcurrent title; higher subpagenames show asbacklinks.
{{ARTICLEPAGENAME}}
Help:Magic words
Title of the subject page associated with the current page. These are useful on talk pages (but see note about Category talk pages).
{{SUBJECTPAGENAME}}
Help:Magic words
{{TALKPAGENAME}}
Help talk:Magic words
Title of the talk page associated with the current page. Useful on subject pages.
{{NAMESPACENUMBER}}
12
Number of the current page's namespace.
{{NAMESPACE}}
Help
Namespace of the title.
{{ARTICLESPACE}}
Help
On a talk page, the namespace part of the title of the associated subject page.
{{SUBJECTSPACE}}
Help
{{TALKSPACE}}
Help talk
Namespace of the talk page associated with the current page.
{{FULLPAGENAMEE}}, {{PAGENAMEE}}, (etc.)
Help:Magic_words, Magic_words, (etc.)
Adding an E to the end of the above variables, renders the above encoded for use in MediaWikiURLs (i.e. with underscores replacing spaces).
{{SHORTDESC}}
Only works on the English Wikipedia, where it displays a short description below the article title on mobile platforms.SeeWikipedia:Short description.
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}} returnsWikipedia 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}}]].
Page IDs can be associated with articles via wikilinks (i.e.Special:Redirect/page/3235121 goes to this page).To output numbers without commaseparators (for example, as "123456789" rather than "123,456,789"), append the parameter|R.
Adds comma separators to anunformatted_number (e.g. 123456789 becomes 123,456,789). To remove such formatting, use{{formatnum:formatted_number|R}} (i.e.{{formatnum:7,654,321|R}}, for example, produces 7654321).
Formats a date according to user preferences; a default can be given as an optional case-sensitive second parameter for users without date preference; can convert a date from an existing format to any ofdmy,mdy,ymd, orISO 8601 formats, with the user's preference overriding the specified format.
Pad with zeroes '0' to the right or left, to fill the given length; an alternative padding string can be given as a third parameter; the repeated padding string (padstr) will be truncated if its length does not evenly divide the required number of characters.
Used to format dates and times, for ISO format, dots or English month names.#timel and#timefl are based on local time as defined for each wiki; for English Wikipedia, this is identical to#time and#timef. The optional 3rd parameter is the output language code (French, German, Swedish: fr, de, sv, etc.). Example Finnish:{{#time:d F Y|June 30, 2016|fi}} shows: 30 kesäkuu 2016 (June). ISO to German:{{#time:d. M Y|1987-10-31|de}} shows: 31. Okt. 1987. For format codes, see:mw:Help:Extension:ParserFunctions##time. Use the format{{#time: H:i, j F Y (e)|...}} to match the format used by timestamps in signatures. #timef formats a date using a standard format for the selected language, see:mw:Help:Extension:ParserFunctions##timef.
{{gender:user|m_out|f_out|u_out}}
Outputsm_out,f_out oru_out according to whether the gender specified inuser's preferences is, respectively, male, female or unspecified. Other parameter permutations are available, seemw:Help:Magic words#gender andtranslatewiki:Gender.
Only way toevaluate magic wordsinside a tag, in order to generate<tagname>magic</tagname>. Also handles tag attributes. Details atmw:Help:Magic words#tag.
Paths
Function
Description
{{localurl:fullpagename |query}}
Relativepath to page name. Thequery parameter is optional.
{{fullurl:fullpagename |query}}
Absolute path, withoutprotocol prefix (i.e. without "http:" etc.), to page name. Thequery parameter is optional.
{{canonicalurl:fullpagename |query}}
Absolute path, including protocol prefix, to page name. Thequery parameter is optional.
{{filepath:filename}}
Absolute path to the media filefilename.
{{urlencode:string}}
Encodesstring for use in URL query strings;{{urlencode:test string}}, for example, produces: test+string. To encodestring for use in URL paths or MediaWiki page names, append, respectively,|PATH or|WIKI (to produce "test%20string" or "test_string").
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.).
Used to include a pipe character as part of a template argument or table cell contents. Before this was added as a magic word, many wikis implemented this by creatingTemplate:! with| as the content.
Used to include an equal sign as part of a template argument or table cell contents. Before this was added as a magic word, many wikis implemented this by creatingTemplate:= with= as the content.
Substituting and nesting
Magic words can sometimes behave weirdly whensubstituted 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:
Special:Version, see last section "Parser function hooks":a list that should include all of the magic words on this page
{{Ifexist not redirect}}, works with the{{#ifexist:}} expression while allowing redirects to be identified and parsed differently
Notes
^If{{FULLPAGENAME}} is used in a page that istranscluded from another page, it will return the name of the target. {{#invoke:TEMPLATENAME|main}} can be used to determine the name of the template itself.
^abcdef{{CURRENTDAY}},{{LOCALDAY}} and{{REVISIONDAY}} return the day (e.g. "6"), whilst{{CURRENTDAY2}},{{LOCALDAY2}} and{{REVISIONDAY2}} return the day with zero-padding (e.g. "06"). For all two-digit days (i.e. 10 to 31), these are the same.
^abcThese timestamp outputs can be formatted with{{Format revisiontimestamp}} (aka{{FRTS}}). For example, {{FRTS|{{REVISIONTIMESTAMP}}}} turns "20251005161638" into "2025-10-05 16:16:38".
^This shows the last user to edit the page. There is no way to show the user viewing the page with magic words due to technical restrictions.