Help:Magic words

Magic words (which include parser functions, variables and behavior switches) are features of wikitext that enable various instructions to be given to the MediaWiki software (for example, to suppress or position the table of contents), or else serve to produce variable output, as is often required in templates.

A quick reference for magic words can be found on this page. For more complete and updated documentation, refer to following pages on the MediaWiki site:
 *  for all standard magic words, including the "standard" parser functions
 *  for some additional parser functions, including conditional expressions

General information
There are three types of magic words:
 * Behavior switches: uppercase words surrounded by double underscores, e.g.  , or keywords using parser function syntax
 * Variables: uppercase words surrounded by double braces, e.g.   (thus resembling templates)
 * Parser functions: keywords (some beginning #) in double braces with parameters after a colon, e.g.  

Some magic words are case-insensitive, but not all. Whitespace is stripped from the start and end of keywords and parameters, as in template syntax.

Page-dependent magic words will affect or return data about the current page, even if the word is added through a transcluded template or included system message.

It is possible to substitute parser functions and variables in the same way that templates are substituted (using the subst: keyword). This causes their current value (as evaluated at the time of substitution) to be written into the wikitext.

Behavior switches
For documentation, refer to the section of the MediaWiki page.

Variables
For documentation, refer to the section of the MediaWiki page.
 *   (page title including namespace)
 *   (page title excluding namespace)
 *   (page title excluding subpage and namespace)
 *   (subpage part of title)
 *  </tt> (associated non-talk page)
 *  </tt> (associated talk page)
 *  </tt> (namespace of current page)
 * , </tt> (associated non-talk namespace)
 *  </tt> (associated talk namespace)
 * , </tt> etc. (URL-encoded equivalents)

The above can all take a parameter, to operate on a page other than the current page.


 *  </tt>
 *  </tt>
 *  </tt>
 *  </tt>
 *  </tt> (current MediaWiki version)
 *  </tt> (latest revision to current page)
 * , , , , , </tt> (date, time, editor at last edit)


 *  2024, August, August, August, 27,, , Tuesday, , , , </tt> (current date/time variables)
 *  2024 </tt> etc. (as above, based on site's local time)


 * , , , , , , , </tt> (statistics on FamilySearch Wiki; add <tt>:R</tt> to return numbers without commas)

Parser functions
These are documented at the unless otherwise stated.

Metadata

 * <tt> </tt> (size of page in bytes)
 * <tt> </tt> (protection level for given action on the current page)
 * <tt> </tt> (number of pages in the given category)
 * <tt> </tt> (number of users in a specific group)

Add <tt>|R</tt> to return numbers without commas.

Formatting

 * <tt> string </tt> (convert to lower case)
 * <tt> string </tt> (convert first character to lower case)
 * <tt> STRING </tt> (convert to upper case)
 * <tt> String </tt> (convert first character to upper case)
 * <tt> NaN </tt> (format a number with comma separators; add <tt> | R</tt> to unformat a number)
 * <tt> </tt> (formats a date according to user preferences; a default can be given as a second parameter for users without date preference); however, please note that the community voted against the concept of date-autoformatting in the, and that there is considerable opposition to the use of this parser function.
 * <tt> xyz </tt>, <tt> xyz </tt> (pad with zeros to the right or left; an alternative padding string can be given as a third parameter)
 * <tt> NaN iss </tt> (produces alternative text according to whether n is greater than 1)
 * <tt> </tt> (for date/time formatting; also <tt>#timel</tt> for local time. Covered at the .)

Paths

 * <tt> </tt>, <tt>  </tt> (relative path to the title)
 * <tt> </tt>, <tt>  </tt> (absolute path to the title)
 * <tt> </tt> (absolute URL to a media file)
 * <tt> </tt> (input encoded for use in URLs)
 * <tt> </tt> (input encoded for use in URL section anchors)
 * <tt>     </tt> (name for the namespace with index n; use <tt>  </tt> for URL-encoded equivalent)
 * <tt> </tt> (converts a relative file path to absolute; see the )
 * <tt> </tt> (splits title into parts; see the )

Conditional expressions
These are covered at the. Some parameters are optional.
 * <tt> </tt> (evaluates the given expression; see Help:Calculation)
 * <tt> </tt> (selects one of two values based on whether the test string is empty)
 * <tt> </tt> (selects one of two values based on whether the test strings are equal – numerically if applicable)
 * <tt> </tt> (selects value based on whether the test string generates a parser error)
 * <tt> </tt> (selects value based on evaluation of expression)
 * <tt> </tt> (selects value depending on whether a page title exists)
 * <tt> </tt> (provides alternatives based on the value of the test string)

For the use of these functions in tables, see Conditional tables.