Magic words are special strings of text that MediaWiki associates with a return value or function. This page explains the standard magic words on the Scratch Wiki.

There are three general types of magic words:

  • Behavior switches: these are usually uppercase words surrounded by double underscores, e.g. "__BAR__".
  • Variables: these are uppercase words surrounded by double braces, e.g. "{{BAZ}}". As such, they are commonly confused with templates.
  • Parser functions: these take parameters and are either of the form "{{foo:...}}" or "{{#foo:...}}"

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.

Note Note: Parameters that are underlined are optional; parameters that are in italics are mandatory.

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.

Word Description
Table of Contents
__NOTOC__ Hides the table of contents
__FORCETOC__ Forces the table of contents to appear at its normal position (before the first header), overriding __NOTOC__
__TOC__ Places the table of contents at the word's position (overriding __NOTOC__). If used multiple times, the table of contents appears at the first word's position.
Editing
__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 normally counterintuitive to the user. 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.
__NEWSECTIONLINK__ Adds a link under "Edit" to add a new section to the end on a non-talk page.
__NONEWSECTIONLINK__ Removes the link under "Edit" to add a new section on talk pages.
Categories
__NOGALLERY__ Used on a category page, replaces thumbnails with normal links.
__HIDDENCAT__ Used on a category page, hides the category from the lists of categories in its members and parent categories.
Search engine indexing
__INDEX__ Tells search engines to index the page (does not override robots.txt).
__NOINDEX__ Tells search engines not to index the page (i.e. prevents the page from showing up in search results).

Variables

Variables return information about the current page, date, or wiki. Their syntax is similar to that of templates. Variables here marked as [expensive] can only have a limited number of them put on a page.

If a template name conflicts with a variable, the variable will be used; i.e. to transclude the template one would have to include the Template: namespace). However, in some cases passing parameters to the variable will transclude the template instead (e.g. {{CURRENTDAYNAME|foo}} transcludes Template:CURRENTDAYNAME, not the variable).

Date and time

These variables return the current date and time in UTC.

Due to browser caching, these variables often show the cached time instead of the actual time.

Word Output Description
Year
{{CURRENTYEAR}} 2018 Year
Month
{{CURRENTMONTH}} 12 Month (zero-padded number)
{{CURRENTMONTH1}} 12 Month (unpadded number)
{{CURRENTMONTHNAME}} December Month (name)
{{CURRENTMONTHNAMEGEN}} December Month (genitive form)
{{CURRENTMONTHABBREV}} Dec Month (abbreviation)
Day
{{CURRENTDAY}} 11 Day of the month (unpadded number)
{{CURRENTDAY2}} 11 Day of the month (zero-padded number)
{{CURRENTDOW}} 2 Day of the week (unpadded number), 0 (for Sunday) through 6 (for Saturday)
{{CURRENTDAYNAME}} Tuesday Day of the week (name)
Time
{{CURRENTTIME}} 12:18 Time (24-hour HH:mm format)
{{CURRENTHOUR}} 12 Hour (24-hour zero-padded number)
Other
{{CURRENTWEEK}} 50 Week (number)
{{CURRENTTIMESTAMP}} 20181211121833 YYYYMMDDHHmmss timestamp

The following variables do the same thing as above but they show the site's server config.

  • {{LOCALYEAR}}
  • {{LOCALMONTH}}
  • {{LOCALMONTH1}}
  • {{LOCALMONTHNAME}}
  • {{LOCALMONTHNAMEGEN}}
  • {{LOCALMONTHABBREV}}
  • {{LOCALDAY}}
  • {{LOCALDAY2}}
  • {{LOCALDOW}}
  • {{LOCALDAYNAME}}
  • {{LOCALTIME}}
  • {{LOCALHOUR}}
  • {{LOCALWEEK}}
  • {{LOCALTIMESTAMP}}

Technical metadata

Note Note: Revision variables return data about the latest edit to the current page, even if viewing an older version of the page.

Word Output Description
{{SITENAME}} Scratch Wiki The wiki's site name
{{SERVER}} https://en.scratch-wiki.info Domain URL
{{SERVERNAME}} en.scratch-wiki.info Subdomain and domain name
{{DIRMARK}}
{{DIRECTIONMARK}}

Outputs a Unicode directional mark that matches the wiki's default language direction, useful in text with multi-directional text
{{SCRIPTPATH}} /w Relative script path
{{STYLEPATH}} /w/skins Relative style path
{{CURRENTVERSION}} 1.28.3 The wiki's MediaWiki version
{{CONTENTLANGUAGE}}
{{CONTENTLANG}}
en
en
The wiki's default interface language
Page
{{PAGEID}} 772 Returns the page identifier
{{PROTECTIONLEVEL:action}} Returns the protection level (e.g. "autoconfirmed" or "EWplus") for a given action (e.g. "edit" or "move") on the current page. Returns an empty string if not protected
Latest revision to current page
{{REVISIONID}} 196549 Unique revision ID
{{REVISIONDAY}} 20 Day edit was made (unpadded number)
{{REVISIONDAY2}} 20 Day edit was made (zero-padded number)
{{REVISIONMONTH}} 05 Month edit was made (zero-padded number)
{{REVISIONMONTH1}} 5 Month edit was made (unpadded number)
{{REVISIONYEAR}} 2018 Year edit was made
{{REVISIONTIMESTAMP}} 20180520045245 Timestamp as of time of edit
{{REVISIONUSER}} Kenny2scratch The last editor of the page, or the current user when previewing an edit
{{REVISIONSIZE}} 31153 The size (in bytes of wikitext) of the current revision of the page
Affects page content
{{DISPLAYTITLE:title|noreplace}} Formats the current page's title header. Changes to the actual title are not allowed besides changing capitalization on the first letter (not including the namespace), style, or replacing underscores with spaces.
It can take a parameter of noreplace to make the word do nothing if another instance of itself already exists on the page
{{DEFAULTSORT:sortkey}}
{{DEFAULTSORTKEY:sortkey}}
{{DEFAULTCATEGORYSORT:sortkey}}
{{DEFAULTSORT:sortkey|noreplace}}
Used for categorizing pages, sets a default category sort key. For example if you put {{DEFAULTSORT:Smith , John}} at the end of John Smith, the page would be sorted under "S" by default in categories. It can take a second argument of noreplace to make the word do nothing if another instance of itself already exists on the page

Statistics

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}}→15,449 and {{NUMBEROFPAGES:R}}→15449).

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.

Word Output Description
{{NUMBEROFPAGES}} 15,449 Number of wiki pages
{{NUMBEROFARTICLES}} 1,190 Number of pages in mainspace
{{NUMBEROFFILES}} 2,940 Number of uploaded files
{{NUMBEROFEDITS}} 218,428 Number of wiki edits
{{NUMBEROFUSERS}} 1,849 Number of registered users
{{NUMBEROFADMINS}} 27 Number of users in the sysop group
{{NUMBEROFACTIVEUSERS}} 72 Number of active users (users with an action in the last month)
{{PAGESINCATEGORY:categoryname}}
{{PAGESINCAT:categoryname}}
65
65
[Expensive] Number of pages (including subcategories and files) in a given category. (Category:Help used for demonstration)
{{PAGESINCATEGORY:categoryname|all}}
{{PAGESINCAT:categoryname|pages}}
{{PAGESINCATEGORY:categoryname|subcats}}
{{PAGESINCAT:categoryname|files}}
65
65
0
0
[Expensive] Respectively, the number of

  • all pages

  • ordinary pages (excluding subcategories and files)

  • subcategories or

  • files
in a given category. (Category:Help used for demonstration)
{{NUMBERINGROUP:groupname}}
{{NUMINGROUP:groupname}}
19
19
(groupname bureaucrat used here)
Number of users in a given usergroup

Page names

Word Output Description
{{FULLPAGENAME}} Help:Magic words Namespace and full page title (including all subpage levels)
{{PAGENAME}} Magic words Full page title (including all subpage) without namespace
{{BASEPAGENAME}} Magic words Page title of the page in the immediately superior subpage level without the namespace ("Title/foo" on "Help:Title/foo/bar")
{{SUBPAGENAME}} Magic words The subpage title ("bar" on "Help:Title/foo/bar")
{{SUBJECTPAGENAME}}
{{ARTICLEPAGENAME}}
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; basically inverse of the above.
{{ROOTPAGENAME}} Magic words Name of the root of the current page. Would return Title on page Help:Title/Foo/Bar

The {{BASEPAGENAME}} and {{SUBPAGENAME}} magic words only work in namespaces that have subpages enabled.

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):

  • {{FULLPAGENAMEE}}
  • {{PAGENAMEE}}
  • {{BASEPAGENAMEE}}
  • {{SUBPAGENAMEE}}
  • {{SUBJECTPAGENAMEE}}
  • {{ARTICLEPAGENAMEE}}
  • {{TALKPAGENAMEE}}
  • {{ROOTPAGENAMEE}}

Namespaces

Word Output Description
{{NAMESPACE}} Help Name of the page's namespace
{{NAMESPACENUMBER}} 12 ID of the page's namespace
{{SUBJECTSPACE}}
{{ARTICLESPACE}}
Help
Help
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):

  • {{NAMESPACEE}}
  • {{SUBJECTSPACEE}}
  • {{ARTICLESPACEE}}
  • {{TALKSPACEE}}

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

  • {{NAMESPACE:Scratch Wiki Home}}(pages in mainspace will return empty)
  • {{NAMESPACE:Template:E}}Template
  • {{SUBJECTSPACE:Template:E}}Template
  • {{TALKSPACE:Template:E}}Template talk

Parameter must not be a namespace name:

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

Other

Word Output Description
{{!}} | Used to include a pipe character as part of a template argument or table cell contents.

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.

Technical metadata of another page

Parser function Output (for page Scratch Wiki Home) Description
{{PAGESIZE:page name|R}} 2,202 [Expensive] Returns the amount of bytes (of wikitext) in the specified page

If an extra parameter R is specified, numbers are returned unformatted (e.g. 132030 instead of 132,030)

{{PROTECTIONLEVEL:action|page name}} sysop [Expensive] Returns the protection level (e.g. "autoconfirmed", "EWplus") for a given action (e.g. "edit", "move") on the specified page. Returns an empty string if not protected.

URL data

Parser function Input → Output Description
{{localurl:page name|query string}} {{localurl:Scratch Wiki Home}}→/wiki/Scratch_Wiki_Home
{{localurl:Scratch Wiki Home|printable=yes}}→/w/index.php?title=Scratch_Wiki_Home&printable=yes
The relative path to the title
{{fullurl:page name|query string}} {{fullurl:Category:Help}}https://en.scratch-wiki.info/wiki/Category:Help
{{fullurl:Category:Help|action=edit}}https://en.scratch-wiki.info/w/index.php?title=Category:Help&action=edit
A protocol-relative path to the title
{{canonicalurl:page name|query string}} {{canonicalurl:Category:Help}}https://en.scratch-wiki.info/wiki/Category:Help The absolute path to the title, using the canonical URL
{{filepath:file name|thumbnail size}} {{filepath:Happy Giga.jpg}}https://en.scratch-wiki.info/w/images/Happy_Giga.jpg
{{filepath:Happy Giga|100}}https://en.scratch-wiki.info/w/images/thumb/Happy_Giga.jpg/100px-Happy_Giga.jpg
A protocol-relative path to the full size or thumbnail of a media file
{{urlencode:string|FORMAT STRING}} {{urlencode:x:y/z á é}} or {{urlencode:x:y/z á é|QUERY}}→x%3Ay%2Fz+%C3%A1+%C3%A9
{{urlencode:x:y/z á é|WIKI}}→x:y/z_%C3%A1_%C3%A9
{{urlencode:x:y/z á é|PATH}}→x%3Ay%2Fz%20%C3%A1%20%C3%A9
The input encoded for use in an URL.
FormatSpace
none+
QUERY+
WIKI_
PATH%20
{{anchorencode:string}} {{anchorencode:x y z á é}}→x_y_z_.C3.A1_.C3.A9 The input encoded for use in URL section anchors (after the # in an URL)

Namespaces

{{ns:}} returns the current localized name for the namespace with that index, canonical name, or local alias. Thus {{ns:6}}, {{ns:File}}, and {{ns:Image}} (an old name for the File namespace) all return "File".

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

Content namespaces Talk namespaces
Usage Output Usage Output
{{ns:-2}} {{ns:Media}} Media
(no talk page)
{{ns:-1}} {{ns:Special}} Special
(no talk page)
{{ns:0}} {{ns:}} {{ns:1}} {{ns:Talk}} Talk
{{ns:2}} {{ns:User}} User {{ns:3}} {{ns:User talk}} User talk
{{ns:4}} {{ns:Project}} {{ns:Scratch Wiki}} Scratch Wiki {{ns:5}} {{ns:Project talk}} {{ns:Scratch Wiki talk}} Scratch Wiki talk
{{ns:6}} {{ns:File}} File {{ns:7}} {{ns:File talk}} File talk
{{ns:8}} {{ns:MediaWiki}} MediaWiki {{ns:9}} {{ns:MediaWiki talk}} MediaWiki talk
{{ns:10}} {{ns:Template}} Template {{ns:11}} {{ns:Template talk}} Template talk
{{ns:12}} {{ns:Help}} Help {{ns:13}} {{ns:Help talk}} Help talk
{{ns:14}} {{ns:Category}} Category {{ns:15}} {{ns:Category talk}} Category talk

Formatting

Usage Input → Output Description
{{formatnum:unformatted number|R}} {{formatnum:65536.2}}→65,536.2
{{formatnum:1,048,576.3|R}}→1048576.3
Takes an unformatted number (arab, no group separators and . as decimal separator) and outputs it in the localized digit script and formatted with decimal and decimal group separators.
The parameter |R basically reverses the process. It takes a number formatted exactly the same way formatnum would and transforms it into a raw number for mathematical uses.
{{#dateformat:date|format}}
{{#formatdate:date|format}}
{{#dateformat:2 may 2017|ymd}}2017 May 2 (your preference); 2017 May 2 (default)
{{#formatdate:2017 may 2|mdy}}May 2, 2017 (your preference); May 2, 2017 (default)
"Your preference" refers to the date format set in your user preferences.
Formats an unlinked date based on user "date format" preference, and adds metadata tagging it as a formatted date. For logged-out users and those who have not set a date format in their preferences, dates can be given a default: mdy, dmy, ymd, ISO 8601 (all case sensitive). If only the month and day are given, only mdy and dmy are valid. If a format is not specified or is invalid, the input format is used as a default. If the supplied date is not recognized as a valid date (specifically, if it contains any metadata such as from a nested use of these or similar templates), it is rendered unchanged, and no (additional) metadata is generated
{{lc:string}} {{lc:BLOCK}}→block Returns the lowercase form of the input
{{lcfirst:string}} {{lcfirst:BLOck}}→bLOck Returns the input with the first letter lowercase
{{uc:string}} {{uc:block}}→BLOCK Returns the uppercase form of the input
{{ucfirst:string}} {{ucfirst:bloCK}}→BloCK Returns the input with the first letter uppercase
{{padleft:xyz|string length|char}}
{{padleft:xyz|string length|string}}
{{padleft:xyz|5}}→00xyz
{{padleft:xyz|5|_}}→__xyz
{{padleft:xyz|5|abc}}→abxyz
{{padleft:xyz|2}}→xyz
{{padleft:|1|xyz}}→x (first character of string)
Inserts a string of padding characters (character chosen in third parameter; default "0") of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; i.e. {{padleft:44|3|0}} produces 044. The padding string may be truncated if its length does not evenly divide the required number of characters.
{{padright:xyz|string length|char}}
{{padright:xyz|string length|string}}
{{padright:xyz|5}}→xyz00
{{padright:xyz|5|_}}→xyz__
{{padright:xyz|5|abc}}→xyzab
{{padright:xyz|2}}→xyz
{{padright:|1|xyz}}→x
Identical to padleft but adds padding characters to the right side

Localization

Usage Input → Output Description
{{plural:which|singular|plural}} {{plural:0|is|are}}→are
{{plural:1|is|are}}→is
{{plural:2|is|are}}→are
{{plural:-1|is|are}}→is
Returns the singular form (second parameter) if which (first parameter) is a number with an absolute value equal to one. Returns the plural form (third parameter) otherwise. Any number (including decimals and negative numbers) are accepted, and a limited number of expressions is also accepted
{{grammar:inflection|word}} {{grammar:N|explode}}→explode Returns the correctly inflected form of the given word. Inflections are in short form (e.g. N for noun or ADJ for adjective)
{{gender:username|text for every gender}}
{{gender:username|male text|female text|text for unspecified}}
{{gender:mres|them}}→them
{{gender:mres|him|her|them}}→them
A switch for the gender set in Special:Preferences.
Note Note: If text for unspecified is not specified and the user's gender is unspecified, male text is returned

Transclusion modifiers

Usage Description
{{:xyz}} A bare colon is not a template modifier but the prefix for the main namespace. Since transclusion defaults to the Template namespace, you would use for example, {{:UTC}} (vs. {{UTC}}) to include the text of the main namespace article UTC rather than Template:UTC
{{msg:xyz}}
{{raw:xyz}}
Even if there is a magic word named "xyz", use template:xyz unless the template doesn't exist (equivalent to {{Template:xyz}}). Normally, magic words have priority when there is a conflict
{{msgnw:xyz}} The content of Template:Xyz is transcluded inside <nowiki> tags
{{subst:xyz}} The tag is changed into the content of Template:Xyz; see Template usage

Miscellaneous

Usage Output Description
{{#special:special page name}}
{{#special:userlogin}}
Special:Special page name
Special:UserLogin
The localized name for the given canonical Special: page
{{#speciale:special page name}}
{{#speciale:userlogin}}
Special:Special_page_name
Special:UserLogin
The localized and URL-encoded name for the given canonical Special: page