Help:Magic words

Shortcut
H:MAGIC

Magic words (including parser functions, variables and behavior switches) are features of wikicode that give instructions to Bulbapedia's underlying MediaWiki software and are especially useful for templates.

  • Behavior switches (e.g. __NOTOC__) will change the behavior of a page, rather than return a value.
  • Variables (e.g. {{PAGENAME}}) will return a value in their place.
  • Parser functions (e.g. {{#ifexpr:Y|Yes|No}}) will take a value and return a value.

Variables and parser functions can use substitution, 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.

Behavior switches

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. Notably some of these are not supported by the Minerva Neue skin.

Word Description
__NOTOC__
Hides the table of contents.
__FORCETOC__
Forces the TOC to appear at the normal location regardless of the number of headings.
__TOC__
Forces the TOC to appear at the point where the magic word is inserted instead of the normal location.
__NOEDITSECTION__
Hides the section edit links beside headings.
__NEWSECTIONLINK__
Adds a link beside the "Edit" tab for adding a new section on a non-talk page.
__NONEWSECTIONLINK__
Removes the link beside the "Edit" tab on pages in talk namespaces.
__HIDDENCAT__
Used on a category page, hides the category from the lists of categories in its members and parent categories.
__EXPECTUNUSEDCATEGORY__
Used on a category page, removes the category from Special:UnusedCategories.
__DISAMBIG__
Identifies a disambiguation page.

Variables

Variables return information about the current page, wiki, or date. Their syntax is similar to templates.

Date & time

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.

Word Output Description
{{CURRENTYEAR}}
2024 Year.
{{CURRENTMONTH}}
12 Month (zero-padded number).
{{CURRENTMONTH1}}
12 Month (unpadded number).
{{CURRENTMONTHNAME}}
December Month (name).
{{CURRENTMONTHABBREV}}
Dec Month (abbreviation).
{{CURRENTDAY}}
3 Day of the month (unpadded number).
{{CURRENTDAY2}}
03 Day of the month (zero-padded number).
{{CURRENTDAYNAME}}
Tuesday Day of the week (name).
{{CURRENTTIME}}
06:36 Time (24-hour HH:mm format).

Technical metadata

Word Output Description
{{SITENAME}}
Bulbapedia The wiki's site name.
{{SERVERNAME}}
bulbapedia.bulbagarden.net Subdomain and domain name.
{{REVISIONDAY}}
9 Day latest revision to current page was made (unpadded number).
{{REVISIONDAY2}}
09 Day latest revision to current page was made (zero-padded number).
{{REVISIONMONTH}}
10 Month latest revision to current page was made (zero-padded number).
{{REVISIONMONTH1}}
10 Month latest revision to current page was made (unpadded number).
{{REVISIONYEAR}}
2024 Year latest revision to current page was made.
{{REVISIONUSER}}
4iamking The username of the user who made the most recent edit to the page (or the current user when previewing an edit).

Statistics

Numbers returned by these variables normally contain commas but can return raw numbers with the ":R" flag (for example, {{NUMBEROFPAGES}} → 280,578 and {{NUMBEROFPAGES:R}} → 280578).

Word Output Description
{{NUMBEROFPAGES}}
280,578 Number of wiki pages.
{{NUMBEROFARTICLES}}
54,996 Number of pages in content namespaces that qualify as articles.
{{NUMBEROFEDITS}}
4,206,167 Number of wiki edits.
{{NUMBEROFFILES}}
0 Number of uploaded files (only useful on Bulbagarden Archives).
{{NUMBEROFUSERS}}
369,776 Number of registered users.
{{NUMBEROFADMINS}}
32 Number of users in the sysop group.
{{NUMBEROFACTIVEUSERS}}
507 Number of active users, based on the criteria used in Special:Statistics.

Page modifiers

Word Description
{{DISPLAYTITLE:title}} 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), adding italics, and replacing spaces with underscores are allowed.
{{DEFAULTSORT:sortkey}} Used for categorizing pages, sets a default category sort key.
For example, if you put {{DEFAULTSORT:Underground, The}} at the end of The Underground, the page would be sorted under "U" by default in categories.

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 levels) without the namespace.
{{BASEPAGENAME}}
Magic words Page title of the page in the immediately superior subpage level without the namespace.
For example, it 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.
{{SUBJECTPAGENAME}}
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.

Namespaces

Word Output Description
{{NAMESPACE}}
Help Name of the page's namespace (except for main space).
{{NAMESPACENUMBER}}
12 ID of the page's namespace.
{{SUBJECTSPACE}}
Help Name of the associated content namespace. Useful on talk pages.
{{TALKSPACE}}
Help talk Name of the associated talk namespace.

Other

Word Output Description
{{!}}
| Used to include a pipe character as part of a template argument or table cell contents.
{{=}}
= Used to include an equal sign 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.

Parser functions can have an impact on system resources, and thus should be used sparingly, and only when strictly necessary. Typically, parser functions are only used in templates.

For details on available parser functions and how to use them, see:

See also