Help:Magic words

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to navigation Jump to search

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 explains only the standard magic words, for information on parser functions (magic words that act similar to variables but take 1 or more parameters) see Help:Parser functions.

General information[edit source]

There are three general types of magic words:

Variables and parser functions can use subst:, just like templates. 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.

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), e.g. <nowiki>{{#magic:}}</nowiki> or {{#magic:<nowiki />}}.

Magic words compared to templates:

  • 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 a # (pound), 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}}.

Behavior switches[edit source]

A behavior switch controls the layout or behavior of the page (if supported by the skin) and can often be used to specify desired omissions and inclusions in the content.

Word Description
Table of contents
__NOTOC__ Hides the table of contents (TOC).
__FORCETOC__ Forces the table of contents to appear at its normal position (before the first header, overriding __NOTOC__).
__TOC__ notoc>__NOTOC__</>). If this is used multiple times, the table of contents will appear at the first word's position.
__NOEDITSECTION__ Hides the section edit links beside headings. This is especially useful where a heading is created from within a template: the normal wiki section-edit would in this case edit the template code, which is usually not what the user intends. Use of this in a template will extend the effect to that template, the pages it's included on, and any other templates included on the same page. For a workaround, see here.
__NEWSECTIONLINK__ Adds a link beside the "Edit" tab for adding a new section on a non-talk page (see Adding a section to the end).
__NONEWSECTIONLINK__ Removes the link beside the "Edit" tab on pages in talk namespaces.
__NOGALLERY__ Used on a category page, replaces thumbnails in the category view with normal links.
__HIDDENCAT__ 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).
__EXPECTUNUSEDCATEGORY__ Used on a category page, removes the category from Special:UnusedCategories.
Language conversion
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).
__START__ No effect. Was used to point where database message starts after comment that should not be transcluded.
__END__ Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace.
__INDEX__ Tell search engines to index the page (overrides $wgArticleRobotPolicies but not robots.txt). It obeys $wgExemptFromUserRobotsControl variable.
__NOINDEX__ Tell search engines not to index the page (i.e. do not list in search engines' results). It obeys $wgExemptFromUserRobotsControl variable.
__STATICREDIRECT__ 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" (which requires $wgFixDoubleRedirects).
From Extensions
Extension Word Description
GlobalUserPage __NOGLOBAL__ Disables the global user page. If present on the central user page, will prevent it from being displayed on remote wikis, and it also determines whether a link to a user page on remote wiki should be red or blue.
Disambiguator __DISAMBIG__ Identifies a disambiguation page.

Variables[edit source]

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 Template:PAGENAME you would need to write {{Template:PAGENAME}}). In some cases, adding parameters will force the parser to invoke a template; for example, {{CURRENTDAYNAME|x}} transcludes Template:CURRENTDAYNAME, not the variable.

Date and time[edit source]

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 use of those variables cause pages to be cached for a more limited number of seconds. This is configured in MagicWordFactory.

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

Variable Output Description
{{CURRENTYEAR}} 2022 Year
{{CURRENTMONTH}} 10 Month (zero-padded number)
{{CURRENTMONTH1}} 10 Month (unpadded number)
{{CURRENTMONTHNAME}} October Month (name)
{{CURRENTMONTHNAMEGEN}} October Month (genitive form)
{{CURRENTMONTHABBREV}} Oct Month (abbreviation)
{{CURRENTDAY}} 2 Day of the month (unpadded number)
{{CURRENTDAY2}} 02 Day of the month (zero-padded number)
{{CURRENTDOW}} 0 Day of the week (unpadded number), 0 (for Sunday) through 6 (for Saturday)
{{CURRENTDAYNAME}} Sunday Day of the week (name)
{{CURRENTTIME}} 12:42 Time (24-hour HH:mm format)
{{CURRENTHOUR}} 12 Hour (24-hour zero-padded number)
{{CURRENTWEEK}} 39 Week (number)
{{CURRENTTIMESTAMP}} 20221002124210 YYYYMMDDHHmmss timestamp

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

  • {{LOCALDAY}}
  • {{LOCALDAY2}}
  • {{LOCALDOW}}

For more thorough time formatting, or to output the current year and week with better compliance with ISO-8601, you may want to use the #time parser function provided by Extension:ParserFunctions.

Technical metadata[edit source]

Variable Output Description
{{SITENAME}} RuneScape Wiki The wiki's site name ($wgSitename).
{{SERVER}} Domain URL ($wgServer).
{{SERVERNAME}} Subdomain and domain name (not dependent on $wgServerName).


Outputs a Unicode directional mark that matches the wiki's default language's direction (&lrm; on left-to-right wikis, &rlm; on right-to-left wikis), useful in text with multi-directional text. It depends on the page content language.
{{SCRIPTPATH}} Relative script path ($wgScriptPath).
{{STYLEPATH}} /skins Relative style path ($wgStylePath).
{{CURRENTVERSION}} 1.38.3 (baa8831) The wiki's MediaWiki version.




The wiki's default interface language ($wgLanguageCode).
{{PAGEID}} 778462 Returns the page identifier.



British English

Returns the language of the current page. The language code that this variable returns can be converted to a language name using {{#language:...}}.
<translate><!--T:1--> Translated unit. Language: {{TRANSLATIONLANGUAGE}}.</translate>

<translate><!--T:2--> Not translated unit. Language: {{TRANSLATIONLANGUAGE}}.</translate>

Translated unit. Language: en.

Not translated unit. Language: en.

Must be used in a translated page, inside <translate> tags. Returns the language code of the current translation unit. In a translation page, if the unit has been translated, then it returns translation language. Else, it returns source language. The language code that this variable returns can be converted to a language name using {{#language:...}}. Should only be used by translation admins.
{{PROTECTIONLEVEL:action}} Outputs the protection level (e.g. "autoconfirmed", "sysop") for a given action (e.g. "edit", "move") on the current page. Returns an empty string if not protected.
{{PROTECTIONEXPIRY:action}} Outputs the protection expiry (e.g. "20160418155030", "infinity") for a given action (e.g. "edit", "move") on the current page. Returns "infinity" if not protected.
{{CASCADINGSOURCES}} [Expensive] Returns the sources of any cascading protection acting on the current page. Pages will not return their own title unless they transclude themselves.
Latest revision to current page
{{REVISIONID}} 35671606 Unique revision ID. It is empty in preview, thus one can show an error message only in preview. May be disabled in miser mode.
{{REVISIONDAY}} 10 Day edit was made (unpadded number).
{{REVISIONDAY2}} 10 Day edit was made (zero-padded number).
{{REVISIONMONTH}} 11 Month edit was made (zero-padded number).
{{REVISIONMONTH1}} 11 Month edit was made (unpadded number).
{{REVISIONYEAR}} 2021 Year edit was made.
{{REVISIONTIMESTAMP}} 20211110171551 Timestamp as of time of edit.
{{REVISIONUSER}} 5-x The username of the user who made the most recent edit to the page, or the current user when previewing an edit.
{{REVISIONSIZE}} 33208 The size (bytes of wikitext) of the current revision of this page
Affects page content
Format the current page's title header. The value must be equivalent to the default title: only capitalization changes to certain parts of the title (not all) and replacing spaces with underscores are allowed (this can be changed with $wgRestrictDisplayTitle). It can be disabled or enabled by $wgAllowDisplayTitle; enabled by default.

It can take a second argument of noerror or noreplace to suppress error messages when multiple displaytitles are used on one page or to make this displaytitle do nothing if a displaytitle was already specified earlier in the page.

Used for categorizing pages, sets a default category sort key. For example if you put {{DEFAULTSORT:McCambridge, John}} at the end of John McCambridge, the page would be sorted under "M" by default in categories. It can take a second argument of noerror or noreplace to suppress error messages when multiple defaultsortkeys are used on one page or to make this defaultsort do nothing if a defaultsort was already specified earlier in the page.

Statistics[edit source]

Numbers returned by these variables normally contain separators (commas, dots or spaces, depending on the local language) but can return raw numbers with the ":R" flag (for example, {{NUMBEROFPAGES}} → 687,961 and {{NUMBEROFPAGES:R}} → 687961).

Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example {{PAGESINCATEGORY:Help}} and {{PAGESINCATEGORY:Help|R}}, or {{PAGESINCATEGORY:Help|subcats}} and {{PAGESINCATEGORY:Help|subcats|R}}). Also applicable to {{PAGESIZE:page name}} hereinbefore.

The number magic words are formatted in the wiki content language. It depends on the page content language.

Variable Output Description
{{NUMBEROFPAGES}} 687,961 Number of wiki pages.
{{NUMBEROFARTICLES}} 63,744 Number of pages in content namespaces that qualify as articles. See Manual:$wgArticleCountMethod for details.
{{NUMBEROFFILES}} 136,957 Number of uploaded files.
{{NUMBEROFEDITS}} 8,722,107 Number of wiki edits.
{{NUMBEROFVIEWS}} Number of page views. Usually useless on a wiki (such as this one) using caching.
{{NUMBEROFUSERS}} 155,853 Number of registered users.
{{NUMBEROFADMINS}} 40 Number of users in the sysop (we call them Administrators) group.
{{NUMBEROFACTIVEUSERS}} 437 Number of active users, based on the criteria used in Special:Statistics.
[Expensive] Number of pages (including subcategories and files) in the given category. (Category:Help used for demonstration)

Respectively, the number of

  • all pages
  • ordinary pages (excluding subcategories and files)
  • subcategories or
  • files

in the given category. (Category:Help used for demonstration)

Number of users in a specific group. ({{NUMBERINGROUP:bureaucrat}} used for demonstration)
Not enabled [Expensive] Number of pages in the given namespace (replace index with the relevant namespace index). For instance, {{PAGESINNAMESPACE:14}} will output the number of category pages. {{PAGESINNS:0}} differs from {{NUMBEROFARTICLES}} in that the former includes redirects and disambiguation pages. Disabled by default, enable with $wgAllowSlowParserFunctions.

Page names[edit source]

Variable For current page Description
{{FULLPAGENAME}} Help:Magic words Namespace and full page title (including all subpage levels).
{{PAGENAME}} Magic words Full page title (including all subpage levels) without the namespace.
{{BASEPAGENAME}} Magic words Page title of the page in the immediately superior subpage level without the namespace. Would return Title/Foo on page Help:Title/Foo/Bar.
{{ROOTPAGENAME}} Magic words Name of the root of the current page. Would return Title on page Help:Title/Foo/Bar.
{{SUBPAGENAME}} Magic words The subpage title.

Would return Bar on page Help:Title/Foo/Bar.

If no subpage exists the value of {{PAGENAME}} is returned.

For more complex splitting, use {{#titleparts:}} from the ParserFunctions extension.

Help:Magic words
Help:Magic words
Full page name of the associated subject (e.g. article or file). Useful on talk pages.
{{TALKPAGENAME}} Help talk:Magic words Full page name of the associated talk page.

None of these are affected by changes to the display title using {{DISPLAYTITLE:xxxx}}; the values returned are the original page title.

The {{BASEPAGENAME}} and {{SUBPAGENAME}} magic words only work in namespaces that have subpages enabled. See $wgNamespacesWithSubpages for information on enabling subpages.

These can all take a parameter, allowing specification of the page to be operated on, instead of just the current page:

  • {{PAGENAME:Template:Main Page}}Main Page
Sword Sign.png
Warning: If the page title contains any parts that are "." or "..", the magic word fails returning nothing.
{{PAGENAME:one/./three}} → '. Nothing is returned.
Sword Sign.png
Warning: Page titles containing certain characters, such as apostrophes ' or asterisks *, may produce unexpected results when handled with these magic words, e.g. {{PAGESINCATEGORY:{{PAGENAME}}}}. See bugs T16779, T18474, T37628, T37746. One simple way to fix this is wrapping the pagename in {{#titleparts:}} from the ParserFunctions extension.

URL encoded page names[edit source]

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 {{PAGENAME:...}}, {{PAGENAMEE:...}} and {{urlencode:...}} have distinct implementations. See Manual:PAGENAMEE encoding for details.

Namespaces[edit source]

Variable Output Description
{{NAMESPACE}} Help Name of the page's namespace
{{NAMESPACENUMBER}} 12 ID of the page's namespace
Name of the associated content namespace
{{TALKSPACE}} Help talk Name of the associated talk namespace

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


These can take a full-page-name parameter and will return the requested namespace associated with that page, instead of with the current page:

  • {{NAMESPACENUMBER:MediaWiki}}0
  • {{NAMESPACE:MediaWiki}} (Pages in main space will return empty)
  • {{NAMESPACE:Template:Main Page}}Template
  • {{SUBJECTSPACE:Template:Main Page}}Template
  • {{ARTICLESPACE:Template:Main Page}}Template
  • {{TALKSPACE:Template:Main Page}}Template talk

Parameter must not be a namespace name:

  • {{SUBJECTSPACE:Help talk}}  (Empty)

Other[edit source]

Variable Output Description
{{!}} | Used to include a pipe character as part of a template argument or table cell contents. Before this was added as a magic word, it was implemented by creating the Template:! with | as the content.

Parser functions[edit source]

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 wiki (as well as the Old School RuneScape Wiki, Brazilian-Portuguese RuneScape Wiki, and RuneScape Classic Wiki) includes the ParserFunctions extension which adds additional functions to those included with MediaWiki. For documentation an all the available parser functions please see Help:Parser functions.

See also[edit source]