Help:Variable
A variable can be considered a predefined template.
This is a list of variables that can be used in the wikitext. The way they are rendered vary with time (directly depending on time, or e.g. for number of articles, depending on the creation of other articles), on the project (it changes when the wikitext is copied), or on the page in which it occurs (it changes when the wikitext is copied, when the page is renamed, and when the page is included in another page).
On the left is the variable, on the right how it is rendered at this time, in this project, on this page.
The names of the variables form part of the set of so-called "magic words" the system uses.
Contents
Constants depending on parameters
Most of the following "constants" are in fact colon functions also known as predefined templates, and might change, e.g. if the {{SERVERNAME}} is changed. They are listed here for historical reasons:
{{ns:-2}} {{ns:Media}}
|
Media Media |
{{ns:-1}} {{ns:Special}}
|
Special Special |
{{ns:0}} ( main namespace )
|
{{ns:0}} ( empty string ) |
{{ns:1}} {{ns:Talk}}
|
Talk Talk |
{{ns:2}} {{ns:User}}
|
User User |
{{ns:3}} {{ns:User_talk}}
|
User talk User talk |
{{ns:4}} {{ns:Project}}
|
wiki.thepatternofeverything.org wiki.thepatternofeverything.org |
{{ns:5}} {{ns:Project_talk}}
|
wiki.thepatternofeverything.org talk wiki.thepatternofeverything.org talk |
{{ns:6}} {{ns:Image}}
|
File File |
{{ns:7}} {{ns:Image_talk}}
|
File talk File talk |
{{ns:8}} {{ns:MediaWiki}}
|
MediaWiki MediaWiki |
{{ns:9}} {{ns:MediaWiki_talk}}
|
MediaWiki talk MediaWiki talk |
{{ns:10}} {{ns:Template}}
|
Template Template |
{{ns:11}} {{ns:Template_talk}}
|
Template talk Template talk |
{{ns:12}} {{ns:Help}}
|
Help Help |
{{ns:13}} {{ns:Help_talk}}
|
Help talk Help talk |
{{ns:14}} {{ns:Category}}
|
Category Category |
{{ns:15}} {{ns:Category_talk}}
|
Category talk Category talk |
{{ns:100}} {{ns:102}} , etc.
|
(customized ) |
{{ns:101}} {{ns:103}} , etc.
|
|
{{SITENAME}}
|
wiki.thepatternofeverything.org |
{{SERVER}}
|
http://wiki.archetypepattern.org |
{{SERVERNAME}}
|
wiki.archetypepattern.org |
{{localurl:fullpagename}}
|
/index.php?title=Fullpagename |
{{localurl:page|query=x}}
|
/index.php?title=Page&query=x |
{{localurl:a&b!}}
|
/index.php?title=A%26b! /index.php?title=A%26b! |
{{urlencode:a&b!}}
|
a%26b%21 |
<code>{{fullurl:fullpagename}} | http://wiki.archetypepattern.org/index.php?title=Fullpagename |
Depending on page
{{PAGENAME}}
|
{{NAMESPACE}}
|
{{REVISIONID}}
|
Variables
For the rendering on page A, these variables depend on page A, even if page A contains the variable due to inclusion of page B. Variables in the sort key of a category tag refer to the page with the tag, not the category page where it takes effect.
Namespace
{{NAMESPACE}} and {{NAMESPACEE}} return an empty string in the article namespace {{ns:0}}, see above and NS:0.
Page Name
PAGENAMEE displays the page title in the form that is used in URLs, i.e. with underscores for spaces, and percent-encoding for special characters, and is therefore used for constructing URLs incl. query strings.
Links and Magic Words
See Help:Link and Help:Magic words for other examples.
Subpages
In a subpage, [[../]] renders as a link to the parent page. See Help:Link#Subpage feature.
Varying with time
{{CURRENTYEAR}}
|
2025 | {{CURRENTMONTH}}
|
02 | |
{{CURRENTMONTHNAME}}
|
February | {{CURRENTMONTHABBREV}}
|
Feb | |
{{CURRENTMONTHNAMEGEN}}
|
February | {{CURRENTWEEK}}
|
9 | |
{{CURRENTDAY}}
|
24 | {{CURRENTDAY2}}
|
24 | |
{{CURRENTDAYNAME}}
|
Monday | {{CURRENTDOW}}
|
1 | |
{{CURRENTTIME}}
|
09:17 | |||
{{NUMBEROFARTICLES}}
|
1,582 | |||
{{NUMBEROFFILES}}
|
100 |
Time variables which change more often than once a day are generally useful only as curiosities. Because of the way article HTML is cached, these variables may be wrong by up to 24 hours, and so are not a reliable way to tell the user the current time.
- CURRENTDOW
- 0=Sunday, 1=Monday, .. 6=Saturday.
- CURRENTWEEK
- is the number of the current week (1-53) according to ISO 8601 with no leading zero.
- CURRENTDAY2
- adds a leading zero to days 1...9, this allows to construct the ISO date formats like 2025-02-24T09:17Z.
- CURRENTMONTHNAMEGEN
- is the genitive grammatical form of the month name
- NUMBEROFARTICLES
- see Help:Article count and Special:Statistics..
Substitution
- Main article: Help:Substitution
New NUMBEROF syntax
The "old" (for some weeks) syntax was {{ NUMBEROFitem|R }} to get the "raw" number without fancy comma separators. The new syntax is {{ NUMBEROFitem:R }} with a colon to get the "raw" number of whatever. This also affects the new magic words PAGESINNS and PAGESINNAMESPACE, now disabled by default.
- Using the old format will (try to) include a corresponding template. Because the "old" feature is in fact rather new it might be possible to fix the syntax using What links here:
- NUMBEROF ADMINS, ARTICLES, FILES, PAGES, USERS.
- PAGESINNS 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 100, 101, 102, 103, etc.
Variable in the form of a template call
If the syntax of a template call with parameters is applied with the name of a variable, depending on the variable the parameters are either ignored or cause the variable to be interpreted as a (non-existing) template:
- Variables like {{NUMBEROFPAGES:R}} = 1764 with a "raw" format are always handled as variable, {{NUMBEROFPAGES:R|Para|meter}} = 1764.
- Other variables like {{CURRENTDAYNAME}} = Monday are handled as template for given parameter(s), {{CURRENTDAYNAME|x}} = Template:CURRENTDAYNAME.
- Colon functions like {{lc: Lower Case}} = lower case ignore extraneous parameters, {{lc: Lower|Case}} = lower.
- Colon function ns (e.g. {{ns: 1}} = Talk) gives an empty string for a non-applicable numerical parameter value, and evaluates a non-numerical parameter value as template, even if it has the name of a variable:
- {{ns: 1234}} =
- {{ns: t|abc}} = Template:Ns: t
- {{ns: CURRENTDAYNAME}} = Template:Ns: CURRENTDAYNAME.
- Colon functions like fullurl don't support the ../ notation, and in namespaces supporting subpages this has odd effects: like above, they evaluate such an invalid parameter value as template, see Link/a and Link/a/b. Here it just renders the wikitext:
- {{fullurl:../a}} = Template:Fullurl:../a.
- The cases #2, #4, and #5 resulting in template calls are probably related.
See also
- Help:Colon function
- Help:Substitution - on applying "subst" to a variable or to a template using a variable
- MagicWord.php