Help:Magic Words
This page serves as a help page for Wiki-related tasks. Before making changes, make sure they have been agreed upon. |
A "magic word" is a special function inserted into a page. There are typically four types of magic words: page functions, formatting, variables, and constants. Page functions are input into the page and change how the page handles specific things. Formatting magic words change how strings display. Variables change their value depending on specific scenarios. Constants are less used values that remain the same throughout the site and are only changed manually.
Magic words differ from a classic template as they often do not use parameters. Functions occasionally have a modifier parameter, and formatting usually requires an input string and potentially some modifier parameters.
Page functions
TOC
Function | Description |
---|---|
__TOC__
|
Places table of contents at specified place. Only one table of contents can appear on a page. Only the first-placed one is acknowledged. Overrides __NOTOC__ and |
__FORCETOC__
|
Ensures the table of contents is on the page and placed at its normal position. Overrides __NOTOC__ .
|
__NOTOC__
|
Removes the table of contents from the page. |
{{TOCright}}
|
Places table of contents at current position and floats right. Used sparingly in mainspace. |
{{TOCleft}}
|
Places table of contents at current position and floats left. Used sparingly in mainspace. |
{{TOClimit}}
|
Places table of contents at current position and includes only level 2 and level 3 headers. |
{{TOClimit|<value>}}
|
Places table of contents at current position and includes only headers down to the specified value. E.g. if value = 4, then display level 2, level 3, and level 4 headers. |
Miscellaneous
Function | Description |
---|---|
<div class="popup-button" style="width:150px; position:relative; margin:auto">
<span class="hoverimage">[[File:{INSERTIMAGE}|link={INSERTLINK}|{LINKNAME}]]</span>
<div class="popup" align="left"><div><span>{INSERTFILE}</span><br />{INSERTTEXT}</div></div></div>
|
Makes a hovering image with links. |
__NOEDITSECTION__
|
Removes edit links from headers. |
__NEWSECTIONLINK__
|
Adds new section option next to "edit" tab on pages. Default for talk pages. |
__NONEWSECTIONLINK__
|
Removes new section option next to "edit" tab on pages. |
__NOGALLERY__
|
Changes images in a category to display in article format. |
__HIDDENCAT__
|
Stops the category from visibly appearing on its members and parents. |
{{DISPLAYTITLE:<title>}}
|
Changes h1 title text to specified text. Only works in mainspace. |
{{DEFAULTSORT:<sort>}}
|
Organizes page in its categories by the sort string instead of the article title. |
[[Category:<category>|<sort>]]
|
Organizes page in the specified category by the specified sort string instead of the article title. |
__NOINDEX__
|
Prevents page from showing up in search engines. |
Formatting
Text
All of the below can be substituted with subst:
to print the outcome onto the page.
Function | Example | Description |
---|---|---|
{{lc:<string>}}
|
{{lc:STRiNG}} → string
|
Converts the input string into lowercase. |
{{uc:<string>}}
|
{{uc:strIng}} → STRING
|
Converts the input string into uppercase. |
{{padleft:<string>|<length>}}
|
{{padleft:54|4}} → 0054
|
Adds number of 0s equal to the left of a given string to reach a given length. |
{{padleft:<string>|<length>|<pad>}}
|
{{padleft:s|5|tar}} → tarts
|
Adds a given recursive pad string before the given string to increase the output string to a specified length. |
{{padright:<string>|<length>}}
|
{{padright:5|4}} → 5000
|
Adds number of 0s equal to the right of a given string to reach a given length. |
{{padright:<string>|<length>|<pad>}}
|
{{padright:b|6|an}} → banana
|
Adds a given recursive pad string after the given string to increase the output string to a specified length. |
{{#pad:<string>|<length>|<pad>}}
|
{{#pad:25|4|0}} → {{#pad:25|4|0}}
|
Takes a given string and adds a given pad string to the end until the string is of a given length. |
{{#pad:<string>|<length>|<pad>|<direction>}}
|
{{#pad:h|8|a|left}} → {{#pad:h|8|a|left}}{{#pad:h|8|a|center}} → {{#pad:h|8|a|center}} {{#pad:h|8|a|right}} → {{#pad:h|8|a|right}} |
Takes a given string and appends a given pad string in a given direction (or distributed on either side if "center") until the string is of a given length. |
{{#sub:<string>|<offset>}}
|
{{#sub:heathen|3}} → {{#sub:heathen|3}}{{#sub:heathen|-3}} → {{#sub:heathen|-3}}
|
Displays a given string from after a given character offset. A negative offset has the offset count from the end of the given string. |
{{#sub:<string>|<offset>|<length>}}
|
{{#sub:heathen|1|3}} → {{#sub:heathen|1|3}}{{#sub:heathen|3|-1}} → {{#sub:heathen|3|-1}}
|
Displays a given string from after a given character offset up to a given length. Negative numbers has the offset count from the end of the given string. Negative length works as a negative offset. |
{{#explode:<string>|<delimiter>|<number>}}
|
{{#explode:a-ma-zing|-|0}} → {{#explode:a-ma-zing|-|0}}{{#explode:a-ma-zing|-|2}} → {{#explode:a-ma-zing|-|2}}
|
Displays a given string from a delimiter at a specified number. |
{{char:<string>|<times>}}
|
ba{{char|.|3}} → {{safesubst:#replace:000|0|.}}
|
Repeats a specified string a specified number of times. |
{{formatnum:<number>}}
|
{{formatnum:5000}} → 5,000
|
Formats contained numerical value with commas. |
{{Nth|<number>}}
|
{{Nth|1}} → 1st{{Nth|12}} → 12th{{Nth|103}} → 103rd{{Nth|N}} → Nth
|
Adds two-letter extension to numbers. |
{{Nth|<number>|sup}}
|
{{Nth|1|sup}} → 1st
|
Adds two-letter extension to numbers, and makes them superscript. |
{{round|<number>}}
|
{{round|45.45}} → 45
|
Displays specified number rounded to the nearest decimal place. See Template:Round#Usage for further information. |
Style
All of the below should not be substituted.
Function | Example | Description | ||||||
---|---|---|---|---|---|---|---|---|
<string>}} | Intangir}} → | Hides a specified string from the page. Designed for use with the sortable class to sort by a specified sort-string rather than what it is displayed.
| ||||||
{{glow:<string>}}
|
{{glow:Pretty}} → Pretty
|
Assigns a fading-border to specified string. Not used in mainspace. See Template:Glow#Usage for further information. | ||||||
<hover>}} | hover text}} → hover text | Adds an asterisk that displays specified hover text on mouse over. | ||||||
<string>|<hover>}} | Edge|Edward Geraldine}} → Edge | Displays specified string with specified hover text on mouse over. | ||||||
{{J|<japanese>|<romaji>}}
|
永遠の闇|Eien no Yami}} → {Template:J | Formats Japanese and related text. See Template:J#Usage for further information. | ||||||
{{Quote|<quote>|<speaker>}}
|
I don't like your plan. It sucks.|Yuna}} ->
|
Formats a quote. |
Variables
Page
These variables depend on the page they are used on. All can be substituted with subst:
to print the outcome onto the page.
Function | This | Talk:A/b/c | Description |
---|---|---|---|
{{PAGENAME}}
|
Magic Words | A/b/c | Displays the current page's name including all tiers. |
{{NAMESPACE}}
|
Help | Talk | Displays the current page's namespace. |
{{FULLPAGENAME}}
|
Help:Magic Words | Talk:A/b/c | Displays the current page's namespace and name including all tiers. |
{{SUBPAGENAME}}
|
Magic Words | c | Displays the current page's name including only the rightmost tier. |
{{BASEPAGENAME}}
|
Magic Words | A/b | Displays the current page's parent-tier name. |
{{FULLBASEPAGENAME}}
|
Help:Magic Words | Talk:A/b | Displays the current page's parent-tier namespace and name. |
{{ROOTPAGENAME}}
|
Magic Words | A | Displays the current page's highest-tier namespace. |
{{FULLROOTPAGENAME}}
|
/|0}} | Talk:A | Displays the current page's highest-tier namespace and name. |
{{TALKSPACE}}
|
Help talk | Talk | Displays the current page's talk page namespace. |
{{TALKPAGENAME}}
|
Help talk:Magic Words | Talk:A/b/c | Displays the current page's talk page namespace and name. |
DateTime
These variables use the current time. All can be substituted with subst:
to print the outcome onto the page.
Function | Example | Description |
---|---|---|
{{CURRENTTIMESTAMP}}
|
20240909211856 | Outputs the current date and time in a YYYYMMDDHHmmss format.
|
{{CURRENTDATETIME}}
|
21:18, September 09, 2024 (UTC) | Outputs the current date and time in timestamp format. |
{{CURRENTYEAR}}
|
2024 | Outputs the current year. |
{{CURRENTMONTH}}
|
09 | Outputs the current month since the year. From January (01) to December (12). |
{{CURRENTMONTHNAME}}
|
September | Outputs the name of the current month since the year. |
{{CURRENTMONTHABBREV}}
|
Sep | Outputs the three-letter abbreviation of the name of the current month since the year. |
{{CURRENTWEEK}}
|
37 | Outputs the current week since the year. |
{{CURRENTDAY}}
|
9 | Outputs the current day since the month. |
{{CURRENTDAY2}}
|
09 | Outputs the zero-padded current day since the month. |
{{CURRENTDOW}}
|
1 | Outputs the current day since the week. From Sunday (0) to Saturday (6). |
{{CURRENTDAYNAME}}
|
Monday | Outputs the name of the current day since the week. |
{{CURRENTTIME}}
|
21:18 | Outputs the current time since the day in a HH:mm format.
|
{{CURRENTHOUR}}
|
21 | Outputs the current hour since the day. From 00 to 23. |
{{CURRENTMINUTE}}
|
18 | Outputs the current minute since the hour. From 00 to 59. |
{{CURRENTSECOND}}
|
56 | Outputs the current second since the minute. From 00 to 59. |
Statistics
These are automated counters. All can be substituted with subst:
to print the outcome onto the page.
Function | Example | Description |
---|---|---|
{{NUMBEROFARTICLES}}
|
3,687 | Displays the total number of articles and disambiguation pages on the wiki. |
{{NUMBEROFPAGES}}
|
92,019 | Displays the total number of pages in all namespaces on the wiki. |
{{NUMBEROFFILES}}
|
73,217 | Displays the total number of files on the wiki. |
{{NUMBEROFEDITS}}
|
395,973 | Displays the total number of edits made to the wiki. |
{{NUMBEROFUSERS}}
|
24,913 | Displays the total number of users signed up to the site. |
{{NUMBEROFACTIVEUSERS}}
|
193 | Displays the total number of users who have edited recently on the wiki. |
{{NUMBEROFADMINS}}
|
16 | Displays the total number of users in the Administrators group on the wiki. |
Expensive
"Expensive" functions should not be used in templates and used only sparingly in content. The number used are tracked and too many uses on a page will break their functionality.
Function | Example | Description |
---|---|---|
{{PAGESINCATEGORY:<category>}}
|
{{PAGESINCATEGORY:Help Pages}} → 0
|
Displays the total number of pages in a specified category. |
Constants
Constants are still technically variables, however unlike the aforementioned variables which are designed to vary under different circumstances, the constants are global and are designed to remain the same across the whole site and at all times. Most constants can be changed, however this is only likely to occur under rare conditions.
Despite their rarity, they are encouraged to be used instead of referring to the same thing in words in the unlikelihood that the constants are changed.
Function | Example | Description |
---|---|---|
{{SITENAME}}
|
{{SITENAME}} → Wikizilla
|
Displays the name of the wiki. |
{{SERVER}}
|
{{SERVER}} → https://wikizilla.org
|
Displays the URL of the website. |
{{SERVERNAME}}
|
{{SERVERNAME}} → wikizilla.org
|
Displays the URL of the website without the data transfer protocol. |
{{ns:<id>}}
|
{{ns:-2}} → Media{{ns:-1}} → Special{{ns:0}} → {{ns:1}} → Talk{{ns:2}} → User{{ns:3}} → User talk{{ns:4}} → Wikizilla{{ns:5}} → Wikizilla talk{{ns:6}} → File{{ns:7}} → File talk{{ns:8}} → MediaWiki{{ns:9}} → MediaWiki talk{{ns:10}} → Template{{ns:11}} → Template talk{{ns:12}} → Help{{ns:13}} → Help talk{{ns:14}} → Category{{ns:15}} → Category talk{{ns:112}} → '{{ns:113}} → '
|
Displays the namespace relating to the id. These are not encouraged to be used, and specifying the namespace name is preferred. In the case of "Wikizilla:" space, "Project:" is preferred. |
{{group|<id>}}
|
{{group|all}} → [[|(all)]]{{group|user}} → Users{{group|wikistaff}} → Staff{{group|rollback}} → Moderators{{group|sysop}} → Administrators{{group|bureaucrat}} → Bureaucrats{{group|bot}} → Bots
|
Template for displaying and linking to user groups. See Template:Group#Usage for further information. |
{{MediaWiki:Forum-archive-months}}
|
{{MediaWiki:Forum-archive-months}} → MediaWiki:Forum-archive-months
|
Displays the number of months of inactivity a thread must undergo before falling into the archives. |
|