Help:Magic words
You don't need to be Editor-In-Chief to add or edit content to WikiDoc. You can begin to add to or edit text on this WikiDoc page by clicking on the edit button at the top of this page. Next enter or edit the information that you would like to appear here. Once you are done editing, scroll down and click the Save page button at the bottom of the page.
This is an organized index of Magic words used in MediaWiki.
Contents |
Table of contents
- For details see Help:Section
| Word | Explanation |
|---|---|
| __NOTOC__ | Hides ToC on the current page. |
| __FORCETOC__ | Forces the table of contents to appear. |
| __TOC__ | Places a ToC here (overriding any __NOTOC__). Multiple ToCs are no longer supported. If __TOC__ is used multiple times, only the first occurence causes a ToC to appear. |
Other
| Word | Explanation |
|---|---|
| __NOEDITSECTION__ | Hides the edit links beside headings. |
| __NEWSECTIONLINK__ | [MW1.7+] 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__ | [MW1.7+] This magic word allows images in category pages to be displayed as inline links instead of gallery. |
| __NOTITLECONVERT__ __NOTC__ | Like __NOCC__ but affecting article title only. |
| __END__ | Allows for trailing whitespace to be included in the page save (does not seem to work anymore). |
| __START__ | This magic word has no effect but an ID in MagicWord.php (MAG_START).
|
XML-style tags
nowiki: <nowiki>...</nowiki>, disables expansion/interpretation of templates, link syntax, formatting syntax, etc.: <nowiki>'''[[{{tc}}]]'''</nowiki> gives '''[[{{tc}}]]'''
noinclude: <noinclude>...</noinclude>, specifies text to appear or function calls to apply only on the transcluded page, not on the transcluding page. E.g. categorizing of a template itself (and not the transcluding page) would use this tag.
includeonly: <includeonly>...</includeonly>, specifies text to appear or function calls to apply only on the transcluding page, not on the transcluded page (which usually is a template). E.g. a template which categorizes pages where it's applied, but not the template itself, into a certain category.
onlyinclude: <onlyinclude>...</onlyinclude>, specifies text to appear or function calls to apply only on the transcluding page, not on the transcluded page. This tag is distinguished from the <includeonly> tag in that text or code on the transcluded page not enveloped by the tag will not be transcluded, whether or not the <noinclude> tag is in use.
pre: <pre>...</pre>, ditto, also for multiple lines; it is rendered with a new paragraph at the start and end: a<pre>'''[[{{tc}}]]'''</pre> gives a'''[[{{tc}}]]'''
math: <math>...</math>, e.g. <math>\sqrt{a^2+b^2}</math> gives
; see Help:Displaying a formula
hiero: <hiero>...</hiero>, e.g. <hiero>A1</hiero> gives: <hiero>A1</hiero>
categorytree: <categorytree>...</categorytree> provides a dynamic view of the category structure specified as a tree. See mw:Extension:CategoryTree for optional attributes.
See also: Extending wiki markup.
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}} | 16
| Displays the current day in numeric form. |
| {{CURRENTDAY2}} | 16
| [MW1.6+] Same as {{CURRENTDAY}}, but with leading zero (01 .. 31). |
| {{CURRENTDAYNAME}} | Thursday
| Name of the day in the language of the project or English. |
| {{CURRENTDOW}} | 4
| Same as {{CURRENTDAYNAME}}, but as a number (0=Sunday, 1=Monday...). |
| {{CURRENTMONTH}} | 10
| The number 01 .. 12 of the month. |
| {{CURRENTMONTHABBREV}} | Oct
| [MW1.5+] Same as {{CURRENTMONTH}}, but in abbreviated form (Jan .. Dec). |
| {{CURRENTMONTHNAME}} | October
| Same as {{CURRENTMONTH}}, but in named form (January .. December). |
| {{CURRENTTIME}} | 00:21
| The current time (00:00 .. 23:59). |
| {{CURRENTHOUR}} | 00
| The current hour (00 .. 23). |
| {{CURRENTMINUTE}} | Template:CURRENTMINUTE
| The current minute (00 .. 59). |
| {{CURRENTSECOND}} | Template:CURRENTSECOND
| The current second (00 .. 59). |
| {{CURRENTWEEK}} | 42
| Number of the current week (1-53) according to ISO 8601 with no leading zero. |
| {{CURRENTYEAR}} | 2008
| Returns the current year. |
| {{CURRENTTIMESTAMP}} | 20081016002142
| [MW1.7+] 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). (All words [MW1.8+] )
| 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}} | 10
| The number 01 .. 12 of the month. |
| {{LOCALMONTHABBREV}} | Oct
| Same as {{LOCALMONTH}}, but in abbreviated form as Jan .. Dec. |
| {{LOCALMONTHNAME}} | October
| Same as {{LOCALMONTH}}, but in named form as January .. December. |
| {{LOCALTIME}} | 20:21
| The local time (00:00 .. 23:59). |
| {{LOCALHOUR}} | 20
| The local hour (00 .. 23). |
| {{LOCALWEEK}} | 42
| Number of the local week (1-53) according to ISO 8601 with no leading zero. |
| {{LOCALYEAR}} | 2008
| Returns the local year. |
| {{LOCALTIMESTAMP}} | 20081015202142
| ISO 8601 time stamp. |
- See also the ParserFunction #time:
Statistics
Statistics variables give thousands separators unless ":R" for "raw" is added (actually, these versions are parser functions).
| Word | Example | Explanation |
|---|---|---|
| {{CURRENTVERSION}} | 1.13.1
| [MW1.7+] Template:H:mwg [1] |
| {{NUMBEROFEDITS}} {{NUMBEROFEDITS:R}} | 382,585382585
| [MW1.10+ (r21319)] Returns the total number of page edits since MediaWiki, the software that runs this site, was installed. |
| {{NUMBEROFARTICLES}} {{NUMBEROFARTICLES:R}} | 75,04075040
| A variable which returns the total number of articles on the Wiki. |
| {{NUMBEROFPAGES}} {{NUMBEROFPAGES:R}} | 140,571140571
| [MW1.7+] Returns the total number of pages. [2] |
| {{NUMBEROFFILES}} {{NUMBEROFFILES:R}} | 16,03416034
| [MW1.5+] Returns the number of uploaded files (rows in the image table). |
| {{NUMBEROFUSERS}} {{NUMBEROFUSERS:R}} | 703703
| [MW1.7+] Returns the number of registered users (rows in the user table). |
| {{NUMBEROFADMINS}} {{NUMBEROFADMINS:R}} | 2020
| [MW1.7+] Returns the number of administrators (users in the sysop group). |
| {{PAGESINNAMESPACE}} | disabled here | Longer alias of PAGESINNS |
| {{PAGESINNS:ns}} {{PAGESINNS:ns:R}} | {{PAGESINNS:2}} {{PAGESINNS:2:R}} disabled here | [MW1.7+] Returns the number of pages in the given namespace. Disabled by default, enable with Template:H:mwg. |
Page names and related info
Parser functions
- For details see Help:Parser function.
Not working at the position of the page where the tag is located but on the page header, and throughout the page, respectively (see below):
- DISPLAYTITLE: allow the page header to be different from the page name.
- DEFAULTSORT: Sets a default category sort key for the page.
Formatting
| Word | Example | Explanation |
|---|---|---|
| {{#language:}} | {{#language:da}} = Dansk
| [MW1.7+] Native name of language code. |
| {{lc:}} | {{lc:AbC dEf}} = abc def
| [MW1.5+] LowerCase |
| {{lcfirst:}} | {{lcfirst:Ab Cd}} = ab Cd
| [MW1.5+] LC first char. |
| {{uc:}} | {{uc:aBc DeF}} = ABC DEF
| [MW1.5+] UpperCase |
| {{ucfirst:}} | {{ucfirst:aB cD}} = AB cD
| [MW1.5+] UC first char. |
| {{formatnum:}} | {{formatnum:-299792458.56789}} = -299,792,458.56789
| [MW1.7+] Add decimal separators according to the wiki's default locale. Leading minus and plus are recognized. |
| {{padleft:}} {{padright:}} |
{{padleft:7|3|0}} = {{padleft:bcd|6|{{!}}}} = | First case is, for example, applicable to years in a category... giving an ordered year to sort by pipetricks order, or any such ordering where left extended zeros allow a proper sorting. [MW1.8+] 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 Padding "0" does not work, it returns the same. This seems to be a bug.[1] |
With regard to #language and m:Template:n local (talk, backlinks, edit), see also:
- List of Wikipedias/local names - shows both names for all languages, without automatic comparison
- List of Wikipedias/local names/diff - values of #language for which {{n local}} contains a different name.
- List of Wikipedias/local names/diff 1 - for languages where the two names are different, shows both; due to the Template:Peisl the end of the table is messed up
Image modifiers
- For details see w:en: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 caption for framed images or together with thumbnails. It's also used as description alt=text.
| Word | Usage | Explanation |
|---|---|---|
| framed frame enframed | [[Image:Mediawiki.png|framed]] | Places an image in a frame with a description. Uses original size and stubbornly ignores width parameter if given. In general, far better to use thumb, as is only suitable for small images. |
| border | [[Image:Mediawiki.png|border]] | Shows a 1px border around the image. |
| thumbnail thumb | [[Image:Mediawiki.png|thumbnail]] | Modifies image size, sets it dependent on user's favorite thumbnail size in one's preferences, or on the given width parameter (see below). |
| thumb=xyz | [[Image:Mediawiki.png|thumb=Wiki.png]] | Manualthumb: instead of displaying an automatically-sized thumbnail for Mediawiki.png, display the image Wiki.png. |
| width px 100x200px | [[Image:Mediawiki.png|40px]] [[Image:Mediawiki.png|100x200px]] | Scales image to given width in pixels Scales image to no more than 100 pixels wide and no more than 200 high, but image scaled to retain its true aspect ratio within the boundary specified. |
Position
- For details see Help:Images and other uploaded files
The positions are mutually exclusive; the last specified wins. Template:- can stop floating. For inline images only 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. |
Miscellany
| Word | Example | Explanation |
|---|---|---|
| {{DISPLAYTITLE:xyz}} | [MW 1.7+] Set the page's title [3], enabled in Wikimedia projects since June 2007 ([4]). Also see Template:H:mwg. | |
| {{DIRMARK}} {{DIRECTIONMARK}} |
| [MW1.7+] u+200E left to right or u+200D right to left mark |
| {{CONTENTLANGUAGE}} | en
| [MW1.7+] code of the site's default interface language (Template:H:mwg) |
| {{DEFAULTSORT:xyz}} | {{DEFAULTSORT:xyz}} | [MW1.10+] Sets a default category sort key for the whole current page (also applying for category tags before this tag)[1]. |
| #REDIRECT | #REDIRECT [[target]]at top of source page | Creates a redirect to another page. |

