When you hear the phrase "magic words", your first thought may be, "Is this some kind of hocus pocus mumbo jumbo?" Well in some cases it may be, but in terms of MediaWiki, a magic word is a keyword or phrase that triggers the software to do something special on a page. Mediawiki looks for magic words when a page is loaded for viewing. If a magic word exists on the page, the software runs the function associated with that magic word. Most magic words display text on the page or have some other form of output. Allow me to pull some knowledge out of my hat to share with you.


In general, magic words help to accomplish tasks in the MediaWiki software that aren't possible otherwise. From text manipulation and formatting, to complex math and common programming if/then/else statements... it's all possible with built-in magic words.

There are three basic types of magic words: behavioral switches, variables, and parser functions. In addition to this, there are a few Wikia-specific magic words.

Behavioral switches

Behavioral switches are denoted by uppercase words surrounded by double underscores, e.g. __TOC__ (which places the Table of Contents at the location of the magic word rather than automatically at the top of the page). Behavioral switches are typically used to hide elements of a page, such as hiding the Table of Contents, like I did on this blog (with __NOTOC__) or the section edit links (with __NOEDITSECTION__). These magic words are unique in that they typically have no output. In fact, almost all of them remove parts of the page when viewed.

Full list: Behavior switches


Variables are also uppercase words, but these are surrounded by double braces, similar to templates, e.g. {{LOCALDAYNAME}} (which displays the day of the week => Saturday). Variables can be quite helpful as most of them are used to display information, such as the current time and date. Other variables can be used to display wiki-specific information, such as the sitename (with {{SITENAME}}) or the number of edits on a wiki (with {{NUMBEROFEDITS}}). These can be used to add a dynamic element to your wiki.

Full list: Variables

Parser functions

Parser functions look similar to variables in that they are also surrounded by double braces, but parser functions are not typically written in full caps. Some parser functions are preceded by the # symbol, such as the {{#if:}} function. These are more advanced magic words as they are not simply a phrase or keyword. All parser functions require some data to work with to output the desired information. They typically gather, manipulate, or format text and data. For example, {{formatnum: 123456}} will return format a string of digits with commas, e.g. 123,456. Another great use of parser functions would be to easily format information or add automatic categorization based on provided data in an infobox.

Full list: Parser functions


There are five Wikia-specific magic words for use in MediaWiki:Wiki-navigation and two behavioral switches for the category galleries. You can see those seven examples here.

Adding magic words

That's nice and all, but how do you use them? To add a magic word, simply add the magic word to the content of the page. If the magic word has an output, place the magic word where you'd want that output to be displayed. If it doesn't, it can be placed anywhere on the page (generally at the bottom or top so it's not lost in the content). Magic words will not be replaced with the output they generate and will still exist as the magic word when editing the page.

Visual editor

In the visual editor, magic words are denoted by the green puzzle piece (Puzzle_piece.png). They cannot be edited in the visual editor, but they can be removed and replaced. Highlighting the puzzle piece will show you what code it represents.

Source editor

Magic words can be added, edited and removed as the code itself in the source editor.


Now that you know how to make the magic work, go spread the magic to your own wiki! Abrakadabra! Alakazam! Open Sesame! If you have a tip for using Magic words, please share them in the comments below!

Looking for further help?

Want to stay up to date on the latest feature releases and news from Fandom?
Click here to follow the Fandom staff blog.

Interested in learning more about community management on Fandom?
Click here to view our community management blog.

Would you like insights on wiki building and usability?
Read through our Best Practices guides for keeping your community growing and healthy.

Want to get real-time access to fellow editors and staff?
Join our Official Discord server for registered editors!

Community content is available under CC-BY-SA unless otherwise noted.