FANDOM


Help icon  Contents → Magic words

A "magic word" is a symbol which is recognized by the MediaWiki software and which when seen in the non-commented text of the page, triggers the software to do something other than display that symbol, or transclude a page with that name, but instead to use the symbol directly. A magic word can be:

  • an upper case word, preceded and followed by two underlines "__", e.g. __NOTOC__
  • an XML object, coded similar to HTML, preceded by "<" and followed by ">", e.g. <nowiki>
  • a parser function: similar to a template, a word preceded by the symbols "{{" and followed by "}}", and optionally parameter definitions between pipe characters, except that the part before the first pipe (or without pipes, the text between the braces) contains a colon (":"), e.g. {{ns:3}} and {{#ifexpr:{{{1}}}>3|large|small}}
  • a variable: similar to a template without parameters, a word preceded by the symbols "{{" and followed by "}}", except the word used is in all upper case, e.g. {{CURRENTDAY}}
  • a template modifier
  • an image modifier

If a page in the template namespace has the same name as a magic word, the magic word will be invoked instead. If you discover you absolutely have to define a template with the same name as a magic word, prefix the name of the template with "msg:" or the name of the template namespace ("Template:"). See below for further details if you need this feature.

Magic words between double underscores

Table of contents

For details see Help: Section.
Word Explanation
__NOTOC__ Hides the table of contents on the current page.
__FORCETOC__ Forces the table of contents to appear.
__TOC__ Places a table of contents at the location where the magic word occurs (overriding any __NOTOC__).

Other

Word Explanation
__NOEDITSECTION__ Hides the edit links beside headings.
__NEWSECTIONLINK__ Gives a "+"-link next to the edit-tab to make a new section on a non-talk page.
__NOCONTENTCONVERT__
__NOCC__
Don't perform the content language conversion (character and phase) in article display; for example, Chinese zh with zh_cn, zh_tw, zh_sg, zh_hk.
__NOGALLERY__ Allows images in category pages to be displayed as inline links instead of as a gallery.
__NOTITLECONVERT__
__NOTC__
Like __NOCONTENTCONVERT__ but affecting article title only.
__END__ Allows for trailing whitespace to be included in the page save.

Variables

For details see Help: Variable.

Time

The time in UTC. Note that if the page was displayed by the same user and has not changed (has not been edited) since the last time it was displayed, it is possible that the page may be cached (by the user's browser) and the displayed time or date may not change. Also, if a heavily used page, rather than freshly rendered by the software each time it is generated, is instead being retrieved from a caching system (such as the main page on Wikipedia) the date or time may not change from the last time the page was originally retrieved by the caching hardware or software.

Word Example Explanation
{{CURRENTDAY}} 15 Displays the current day in numeric form.
{{CURRENTDAY2}} 15 Same as {{CURRENTDAY}}, but with leading zero (01 .. 31).
{{CURRENTDAYNAME}} Wednesday Name of the day in the language of the project or English.
{{CURRENTDOW}} 3 Same as {{CURRENTDAYNAME}}, but as a number (0=Sunday, 1=Monday...).
{{CURRENTMONTH}} 07 The number 01 .. 12 of the month.
{{CURRENTMONTHABBREV}} Jul Same as {{CURRENTMONTH}}, but in abbreviated form as Jan .. Dec.
{{CURRENTMONTHNAME}} July Same as {{CURRENTMONTH}}, but in named form January .. December.
{{CURRENTTIME}} 06:27 The current time (00:00 .. 23:59).
{{CURRENTHOUR}} 06 The current hour (00 .. 23).
{{CURRENTMINUTE}} 27 The current minute (00 .. 59).
{{CURRENTWEEK}} 29 Number of the current week (1-53) according to ISO 8601 with no leading zero.
{{CURRENTYEAR}} 2020 Returns the current year.
{{CURRENTTIMESTAMP}} 20200715062700 ISO 8601 time stamp.

Local time

The time depending on the local timezone of the wiki (not depending on the timezone in the user's preference settings).

Word Example Explanation
{{LOCALDAY}} 15 Displays the local day of the month in numeric form.
{{LOCALDAY2}} 15 Same as {{LOCALDAY}}, but with a leading zero (01 .. 31).
{{LOCALDAYNAME}} Wednesday Name of the day in the language of the project or English.
{{LOCALDOW}} 3 Same as {{LOCALDAYNAME}}, but as a number (0=Sunday, 1=Monday...).
{{LOCALMONTH}} 07 The number 01 .. 12 of the month.
{{LOCALMONTHABBREV}} Jul Same as {{LOCALMONTH}}, but in abbreviated form as Jan .. Dec.
{{LOCALMONTHNAME}} July Same as {{LOCALMONTH}}, but in named form as January .. December.
{{LOCALTIME}} 06:27 The local time (00:00 .. 23:59).
{{LOCALHOUR}} 06 The local hour (00 .. 23).
{{LOCALWEEK}} 29 Number of the local week (1-53) according to ISO 8601 with no leading zero.
{{LOCALYEAR}} 2020 Returns the local year.
{{LOCALTIMESTAMP}} 20200715062700 ISO 8601 time stamp.

Statistics

Statistics variables give thousands separators unless ":R" for "raw" is added (actually, these versions are parser functions).

Word Example Explanation
{{CURRENTVERSION}} 1.19.24 Returns the current version of the base MediaWiki software installed on the Law & Order Wiki server. [1]
{{NUMBEROFEDITS}}
{{NUMBEROFEDITS:R}}
148,446
148446
Returns the total number of page edits since MediaWiki, the software that runs the Law & Order Wiki, was installed.
{{NUMBEROFARTICLES}}
{{NUMBEROFARTICLES:R}}
8,559
8559
Returns the total number of articles on the Law & Order Wiki.
{{NUMBEROFPAGES}}
{{NUMBEROFPAGES:R}}
23,254
23254
Returns the total number of pages on the Law & Order Wiki. [2]
{{NUMBEROFFILES}}
{{NUMBEROFFILES:R}}
6,139
6139
Returns the number of files uploaded to the Law & Order Wiki (rows in the image table).
{{NUMBEROFUSERS}}
{{NUMBEROFUSERS:R}}
23,701,859
23701859
Returns the number of registered users (rows in the user table).
{{NUMBEROFADMINS}}
{{NUMBEROFADMINS:R}}
3
3
Returns the number of administrators (sysop, bureaucrat, steward, and checkuser) on the Law & Order Wiki.

Page names and related info

Word Example Explanation
{{PAGENAME}} Magic words Returns the name of the current page, including all levels (Title/Subtitle).
{{PAGENAMEE}} Magic_words More URL-friendly percent-encoded special characters (to use an article name in an external link).
{{SUBPAGENAME}}
{{SUBPAGENAMEE}}
Magic words
Magic_words
Name of the current page, excluding parent pages ("Subtitle" on "Title/Other/Subtitle") in namespaces supporting subpages.
{{BASEPAGENAME}}
{{BASEPAGENAMEE}}
Magic words
Magic_words
The base name of a subpage ("Title/Other" on "Title/Other/Subtitle").
{{NAMESPACE}}
{{NAMESPACEE}}
Help
Help
Returns the name of the namespace the current page resides in.
{{FULLPAGENAME}}
{{FULLPAGENAMEE}}
Help:Magic words
Help:Magic_words
Shorthands for NAMESPACE+PAGENAME
{{TALKSPACE}}
{{TALKSPACEE}}
Help talk
Help_talk
Name of next odd namespace (e.g. 4 → 5)
{{SUBJECTSPACE}}
{{SUBJECTSPACEE}}
Help
Help
Name of last even namespace (e.g. 5 → 4)
{{ARTICLESPACE}}
{{ARTICLESPACEE}}
Help
Help
An alias for SUBJECTSPACE(E)
{{TALKPAGENAME}}
{{TALKPAGENAMEE}}
Help talk:Magic words
Help_talk:Magic_words
FULLPAGENAME in its TALKSPACE
{{SUBJECTPAGENAME}}
{{SUBJECTPAGENAMEE}}
Help:Magic words
Help:Magic_words
FULLPAGENAME in its SUBJECTSPACE
{{ARTICLEPAGENAME}}
{{ARTICLEPAGENAMEE}}
Help:Magic words
Help:Magic_words
An alias for SUBJECTPAGENAME(E)
{{REVISIONID}} 69341 The unique identifying number of a page, used in comparing two versions of the same page, as when viewing the page history. Note that when editing a page, this value is null.
{{REVISIONDAY}} 1 The day on which the page was last modified.
{{REVISIONDAY2}} 01 The day on which the page was last modified, but with a leading zero (01 .. 31).
{{REVISIONMONTH}} 09 The month in which the page was last modified.
{{REVISIONYEAR}} 2015 The year in which the page was last modified.
{{REVISIONTIMESTAMP}} 20150901034241 ISO 8601 time stamp, indicating when the page was last modified.
{{SITENAME}} Law and Order The name of the site ($wgSitename).
{{SERVER}} //lawandorder.fandom.com The base URL of the server {$wgServer).
{{SCRIPTPATH}} The base URL path {$wgScriptPath).
{{SERVERNAME}} lawandorder.fandom.com The name of the server without the protocol ($wgServerName).

Parser functions

For details see Meta: Parser function.

Namespaces and URLs

Word Example Explanation
{{ns:}} {{ns:4}} = Law and Order
{{ns:project}} = Law and Order
Returns the name of a given namespace number.
{{localurl:x y @}}
{{localurle:x y @}}
{{localurl:a|b=c}}
/wiki/X_y_@
/wiki/X_y_@
/wiki/A?b=c
Returns the local URL of a page (might not exist). Optional query parameter, see Variable.
{{urlencode:x y @}} x+y+%40 Encodes variable values for use in external links. [3]
{{anchorencode:x #y @}} x_.23y_.40 Encodes variable values for use in section anchors. [4]
{{fullurl:x y @}}
{{fullurle:x y @}}
{{fullurl:m:a|b=c}}
https://lawandorder.fandom.com/wiki/X_y_@
https://lawandorder.fandom.com/wiki/X_y_@
http://meta.wikimedia.org/wiki/a?b=c
Returns the full URL of a given page. Optional query parameter as for localurl:.

Formatting

Word Example Explanation
{{#language:}} {{#language:da}} = Dansk Native name of language code.
{{lc:}} {{lc:AbC dEf}} = abc def LowerCase
{{lcfirst:}} {{lcfirst:Ab Cd}} = ab Cd LC first char.
{{uc:}} {{uc:aBc DeF}} = ABC DEF UpperCase
{{ucfirst:}} {{ucfirst:aB cD}} = AB cD UC first char.
{{formatnum:}} {{formatnum:-299792458.56789}} = -299,792,458.56789 Adds decimal separators to a number. Leading minus and plus are recognized.
{{padleft:}}
{{padright:}}

{{padleft:7|3|0}} = 007
{{padleft:0|3|0}} = 000
{{padleft:bcd|6|a}} = aaabcd
{{padright:bcd|6|a}} = bcdaaa
{{padleft:café|8|-}} = ----café
{{padleft:cafe|8|-}} = ----cafe
{{padleft:bcd|6|{{!}}}} = |||bcd

Pads a string with a character to the specified width. Note that there's a little bug that interprets non-US-ASCII characters as two, instead of one character (see the difference in café and cafe in the examples).

It does not seem possible to use padleft and padright for padding with characters with a multi-character code, such as &nbsp;, which would be useful with padleft for sorting tables with Javascript.

{{#tag:}} {{#tag:myextension | attr=val | attr2=val2 | content}} = <myextension attr=val attr2=val2>content</myextension> Passes attributes and inner content to an XML-style parser tag, parsing template variables along the way. See Extension:TagParser.

Template modifiers

Usage Explanation
{{:xyz}} A bare colon is not a template modifier, it's the prefix for the main namespace. Test e.g. article {{:UTC}} vs. template {{UTC}}.
Using this syntax you include the text of the main namespace article xyz in another article.
{{int:xyz}} Shorthand for {{MediaWiki:xyz}}, rendered as <xyz> if MediaWiki:xyz doesn't exist. See also System messages.
{{msg: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 unevaluated wikitext is rendered. See msgnw.
{{raw:xyz}} Equivalent to {{msg:xyz}} above[1].
{{subst:xyz}} In the wikitext, the tag is substituted by the content (single-level evaluation only); see Meta: Substitution.

Image modifiers

For details see Wikipedia: Extended image syntax.

These are image modifiers used in [[Image:title.ext|modifier|...|modifier]] links. Some are mutually exclusive, and then the last specified wins.

Size

The last unrecognized modifier is used as a caption for framed images or together with thumbnails. It's also used as a description, i.e. alt=text.

Word Usage Explanation
framed
frame
enframed
[[Image:Mediawiki.png|framed]] Places an image in a frame with a description. Uses original image size.
border [[Image:Mediawiki.png|border]] Displays a 1px border around the image.
thumbnail
thumb
[[Image:Mediawiki.png|thumbnail]] Modifies image size, sets it to dependent on user's favorite thumbnail size in their preferences.
thumb=xyz [[Image:Mediawiki.png|thumb=Wiki.png]] Manualthumb: instead of displaying an automatically-sized thumbnail for Mediawiki.png, displays the image Wiki.png.
width px
n1xn2 px
[[Image:Mediawiki.png|40px]]
[[Image:Mediawiki.png|100x200px]]
Scales image to given width in pixels.
Scales image to no more than n1 pixels wide and no more than n2 high, but image scaled to retain its true aspect ratio within the boundary specified.

Position

For details see Meta: Images and other uploaded files.

The positions are mutually exclusive; the last specified wins. <br clear="all" /> can stop floating. For inline images, only the modifier px (see above) is supported.

Word Usage Explanation
right [[Image:Mediawiki.png|right]] Modifies position, floats the image to the right.
left [[Image:Mediawiki.png|left]] Modifies position, floats the image to the left.
none [[Image:Mediawiki.png|none]] Explicitly states that the image should not float.
center
centre
[[Image:Mediawiki.png|center]] Modifies position, like none but centered.

Miscellaneous

Word Example Explanation
{{DISPLAYTITLE:xyz}} {{DISPLAYTITLE:iTunes}} Sets the page's title to xyz. Note that the character count must match with that of the actual title or the displayed title will be unchanged.
{{DIRMARK}}
{{DIRECTIONMARK}}

u+200E left to right or u+200D right to left mark.
{{CONTENTLANGUAGE}} en Code of the default interface language ($wgLanguageCode).
{{DEFAULTSORT:xyz}} {{DEFAULTSORT:Briscoe, Lenny}} Sets a default category sort key for the whole current page (i.e. also applies to category tags before this magic word)[2].
#REDIRECT #REDIRECT [[target]]
at top of source page
Creates a redirect to another page.

Language-dependent word conversions

Word Example Explanation
{{CURRENTMONTHNAMEGEN}} July Genitive form of the month name; used for Czech, Polish, Ukrainian, etc. [5]
{{grammar:case | word}} {{grammar:7sg|Wikipedie}}
on cs: is Wikipedií.
Derived word forms in inflected languages like Czech. [6]
{{plural:count | form1 | form2}} {{plural: 2 | is | are}}
outputs are
{{plural: 0 | this | these}}
outputs these
count 1 yields form1 (singular), all other values for count yield form2 (plural); plural transformations are used for languages like Russian [7] based on "count mod 10".

"Grammar" and "Plural" are language-dependent functions, defined in [8], [9], etc. (note that in PHP, the modulo operator is the percent sign).

"Grammar" can either be applied to predefined words only, or to arbitrary words, depending on whether the definition is just a 2D array, or involves string manipulations. See also Wikipedia:cs:Šablona:Wikivar/GRAMMAR.

See also

References

  1. Wikimedia SVN revision 12925
  2. "Technology report", en-Wikipedia Signpost, January 2007

A magic word is a keyword or phrase recognized by MediaWiki software (on which Fandom is built), which triggers the software to do something special on the page.

Magicword

An example of magic word input and rendering

Instructions

It's generally best to add and edit magic words using source editing mode.

To add a magic word, simply add the magic word to the content of the page somewhere. It will look like code in the editor, but after you save or preview, it will display as intended.

Visual editing

When editing in the classic rich text editor, magic words that affect the page layout will show up as a green puzzle piece, while magic words that output text will display the text, but that text will not be editable.

In the VisualEditor, magic words that affect the page layout will not show up, while magic words that output text will display the text, but that text will not be editable.

Common magic words

Here are some of the most commonly used magic words:

  • __NOTOC__ hides the table of contents on a page.
  • __TOC__ places the table of contents exactly where this is entered. It overrides the NOTOC switch.
  • __NEWSECTIONLINK__ replaces the "Edit" button with "Add topic", for adding new sections on a non-talk page.
  • __NONEWSECTIONLINK__ replaces the "Add topic" button with "Edit", on talk namespaces.
  • __NOWYSIWYG__ disables the classic editor on a page.
  • __HIDDENCAT__ makes a category hidden.
  • {{CURRENTDAYNAME}} outputs the current day of the week.
  • {{NUMBEROFARTICLES}} outputs the number of articles on your community.
  • {{SITENAME}} outputs the name of the community.
  • {{PAGENAME}} outputs the name of the page the word is placed on.
  • {{FULLPAGENAME}} outputs the full name of the page, i.e. with the namespace prefix, of the page it is placed on.

Full list of magic words

For a full list of available[1] magic words, see the magic words help page on MediaWiki.

Notes

  1. Some magic words may function differently, or not work, at Fandom. This occurs because the version of the MediaWiki software used by Fandom is not always the same version as those of either MediaWiki.org or Wikipedia.
  • {{SUBJECTPAGENAME}} and {{TALKPAGENAME}} (similarly {{SUBJECTPAGENAMEE}} and {{TALKPAGENAMEE}}) may not always act inversely. For example:
    {{TALKPAGENAME:User:Example}} → Message Wall:Example
    {{SUBJECTPAGENAME:Message Wall:Example}} → Message Wall:Example
    {{SUBJECTPAGENAME:User Talk:Example}} → User:Example

See also

Further help and feedback

Community content is available under CC-BY-SA unless otherwise noted.