Help:Magic words for beginners

Magic words are words surrounded by brackets or underscores which most often insert or display the current value of what they are called. These include parser functions, variables and behavior switches and are features of wikitext. They are interpreted by the Metawiki software and are often used in templates so that they show different information depending on which page they are on and many other conditions.

Types
There are three types of magic words:
 * Behavior switches: uppercase words surrounded by double underscores, like.
 * Variables: uppercase words surrounded by double braces, like  and function somewhat similarly to templates.
 * Parser functions: These include expressions and consist of keywords (some beginning #) in double braces with parameters following a colon, ex.

Things to remember

 * Most magic words may be case-sensitive.
 *  ""  produces "", while  ""  produces


 * Whitespace is not counted in from the front and back of keywords and parameters and the same also applies to template code.
 *  "" and will both succeed in producing the "Nofeed" template.


 * Page-dependent magic words will change or show information about the current page, even if the word is from a template, though in most cases, this is the desired effect.
 * If I insert and it says , I will see "Magic words for beginners" even though it is from "Template:example template".


 * If you want a magic word to paste in its value at the time of saving, you can substitute it in the same way that templates are substituted (using the  keyword).
 *  will always display the current time and remain as is, while  will result in, for example, 9:45 being inserted and always remaining as regular text.

Behavior switches
For a more detailed explanation, refer to the behavior switches MediaWiki page.

Table of contents

 * (can be placed anywhere in the wikitext; prevents a table of contents)
 * (can be placed anywhere in the wikitext; makes a table of contents appear in its normal position)
 * (places a table of contents at its position)

Edit/section links

 * (hides section edit links beside headings)
 * (adds a "+" or "new section" link for adding a new section on a non-talk page)
 * (removes the "+" or "new section" link on "Talk" pages)

Categories and indexing

 * (on category pages, replaces thumbnails with normal links)
 * (on category pages, makes it a hidden category)
 * (tells search engines to index the page (show in results))
 * (tells search engines not to index the page (not show in results))

Titles and sorting

 * (changes the displayed form of the page title)
 * (sets a default category sorting key)

Variables


For documentation, you may wish to read the variables MediaWiki page.
 * (The page title, including namespace.)
 * Shown here: (Ex. User:QwerpQwertus/Adoption)


 * (page title without namespace)
 * Shown here: (Ex. User:QwerpQwertus/Adoption)


 * (the page title without the current subpage or namespace — the parent page without the namespace.)
 * Shown here: (Ex. User:QwerpQwertus/Adoption)


 * (subpage part of title)
 * Shown here: (Ex. User:QwerpQwertus/Adoption)


 * (associated non-talk page)
 * Shown here: (Ex. "Talk:Wikipedia" makes "Wikipedia")


 * (associated talk page)
 * Shown here: (Ex. "Wikipedia" makes "Talk:Wikipedia")


 * (namespace of current page)
 * Shown here: (Ex. User:QwerpQwertus/Adoption makes "User")


 * (associated non-talk namespace)
 * Shown here:, (Ex. User talk:QwerpQwertus/Adoption makes "User")


 * (associated talk namespace)
 * Shown here: (Ex. "Wikipedia" makes "Talk:Wikipedia")


 * etc. (URL-encoded equivalents)
 * Shown here: (Ex. "Wikipedia" makes " http://en.wikipedia.org/w/index.php?title=Wikipedia ")

<!-- The above can all take a parameter, to operate on a page other than the current page.
 * ( http://en.wikipedia.org )
 * (current MediaWiki version)
 * (latest revision to current page)
 * (date, time, editor at last edit)
 * (current date/time variables)
 * etc. (as above, based on site's local time)
 * (statistics on English Wikipedia; add  to return numbers without commas)
 * (current date/time variables)
 * etc. (as above, based on site's local time)
 * (statistics on English Wikipedia; add  to return numbers without commas)

Parser functions
These are documented at the main documentation page unless otherwise stated.

Metadata

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

Add  to return numbers without commas.

Formatting

 * (convert to lower case)
 * (convert first character to lower case)
 * (convert to upper case)
 * (convert first character to upper case)
 * (format a number with comma separators; add  to unformat a number)
 * (formats a date according to user preferences; a default can be given as an optional case-sensitive second parameter for users without date preference; can convert a date from an existing format to any of,  ,   or   formats, with the user's preference overriding the specified format)
 * ,  (pad with zeros to the right or left; an alternative padding string can be given as a third parameter)
 * (produces alternative text according to whether n is greater than 1)
 * (for date/time formatting; also  for local time. Covered at the extension documentation page.)
 * (produces alternate text according to the gender specified by the given user in their preferences)

Paths

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

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

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