Magic words are strings of text that MediaWiki associates with a return value or function, such as time, site details, or page names.

Examples include

  • __NOTOC__ - Hides the table of contents (short for "NO Table Of Contents").
  • __NOINDEX__ - Tell search engines not to index the page
  • {{CURRENTYEAR}} - Current year: 2024
  • {{NUMBEROFARTICLES}} - Number of pages in content namespaces: 14,595
  • {{FULLPAGENAME}} - Namespace and page title: Help:Magic words
  • {{PAGENAME}} - Page title: Magic words

There are many, many more, for a wide range of date & time, site statistics & page name data.

For full details, see mw:Help:Magic words.

Parser functions

A parser function is a "magic word" that takes a parameter. This allows more complex functions and calculations to be performed.

Use with care

Please use with care, as needed. Parser function code can easily scare away editors. So...

  • Use in templates, not directly in pages.
  • If you're experimenting with parser function code, especially complex code, use your userspace. E.g. put the template at [[User:Yourname/templatename]], and insert the template using {{User:Yourname/templatename}}. If it proves useful, it can be moved to template space later.
  • If your documentation explains how your template works, this helps future editors of the template.


Standard parser functions

The main use of the standard parser functions are url encoding, date formatting and case formatting. E.g.

https://www.appropedia.org/Page_name outputs a page's url. {{fullurl:passive solar}}https://www.appropedia.org/Passive_solar

For full details, see mw:Help:Magic words #Parser functions.


Extra parser functions

The Parser Functions extension is enabled on Appropedia, giving another 11 functions, including if and switch functions, to perform certain logical operations. Examples include:

  • #expr evaluates an expression as true (1) or false (0). For logical inputs, any non-zero number is true, and 0 is false
    • {{#expr: 1.5*2=3 }} → 1
    • {{#expr: 1.5*2=400 }} → 0
    • {{#expr: 1 and 0 }} → 0
    • {{#expr: 1 or 0 }} → 1
  • #if is a little counterintuitive. It returns a true value if the first parameter is 'non-empty'. If it is empty or only whitespace, it evaluates to false. A mathematical expression is treated as a string and evaluates to true even if the expression itself is false. The second parameter is the 'true' output, and the third and final parameter is the 'false' output:
    • {{#if: blah | rhino | unicorn }} → rhino
    • {{#if: | rhino | unicorn }} → unicorn
    • {{#if: 0 | yes | no }} → yes
  • #ifexpr evaluates a mathematical expression and returns the second parameter string if true, and the third (and last) parameter string if false. E.g.:
    • {{#ifexpr: 1 < 0 | true | false}} → false
    • {{#ifexpr: 1+1=2 | blue | red}} → blue
  • #switch displays the value of one of its parameters, e.g. {{#switch: baz | foo = Foo | baz = Baz | Bar }}

For full details, see mw:Help:Extension:ParserFunctions.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.