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 are not case-sensitive, although some are, so you should be careful
 *  "" 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 subst: 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)
 *  __NEWSECTIONLINK__ </tt> (adds a "+" or "new section" link for adding a new section on a non-talk page)
 *  __NONEWSECTIONLINK__ </tt> (removes the "+" or "new section" link on "Talk" pages)

Categories and Indexing

 *  __NOGALLERY__ </tt> (on category pages, replaces thumbnails with normal links)
 *  __HIDDENCAT__ </tt> (on category pages, makes it a hidden category)
 *  __INDEX__ </tt> (tells search engines to index the page (show in results))
 *  __NOINDEX__ </tt> (tells search engines not to index the page (not show in results))

Titles and Sorting

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

Variables


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


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


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


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


 *  </tt> (associated non-talk page)
 * Shown here: (Ex. "Talk:WikiQueer" makes "WikiQueer")


 *  </tt> (associated talk page)
 * Shown here: (Ex. "WikiQueer" makes "Talk:WikiQueer")


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


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


 * <tt> </tt> (associated talk namespace)
 * Shown here: (Ex. "WikiQueer" makes "Talk:WikiQueer")


 * <tt>, </tt> etc. (URL-encoded equivalents)
 * Shown here: (Ex. "WikiQueer" makes " http://www.wikiqueer.org/mw/index.php?title=WikiQueer ")

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

Parser functions
These are documented at the main documentation page 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 an optional case-sensitive second parameter for users without date preference; can convert a date from an existing format to any of <tt>dmy</tt>, <tt>mdy</tt>, <tt>ymd</tt> or <tt>ISO 8601</tt> formats, with the user's preference overriding the specified format)
 * <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 extension documentation page.)
 * <tt> </tt> (produces alternate text according to the gender specified by the given user in his/her preferences)

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 extension documentation)
 * <tt> </tt> (splits title into parts; see the extension documentation)

Conditional expressions
These are covered at the extension documentation page. 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. -->