• About Good Acts
  • Veterans Resources
  • From Pharms to Farms | A Veteran’s Road to Freedom
  • Petition to Educate the DEA on the Medical Benefits of Cannabis
Good Acts

The best road to progress is freedom's road. - JFK

Texas

Special markup for the MediaWiki software
"WP:MAGIC" redirects here. For WikiProject Magic, see Wikipedia:WikiProject Magic.
"H:MW" redirects here. For the MediaWiki namespace, see Help:MediaWiki namespace. For information about the entire MediaWiki software application, see MediaWiki.
For an introduction, see Help:Magic words for beginners.

Magic words (including parser functions, variables and behavior switches) are features of wiki markup that give instructions to Wikipedia's underlying MediaWiki software. For example, magic words can suppress or position the table of contents, disable indexing by external search engines, and produce output dynamically based on the current page or on user-defined conditional logic. Some of these features are especially useful for templates.

This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation:

  • mw:Help:Magic words: All standard magic words, including the "standard" parser functions.
  • mw:Help:Extension:ParserFunctions: Additional parser functions, including conditional expressions.

Contents

  • 1 General information
  • 2 Behavior switches
  • 3 Variables
    • 3.1 Other variables by type
  • 4 Parser functions
    • 4.1 Metadata
    • 4.2 Formatting
    • 4.3 Paths
    • 4.4 Conditional
    • 4.5 Other
  • 5 See also

General information

In general, there are three types of magic words

  1. Behavior switches: often appear in double underscores, all uppercase, e.g., __NOTOC__. They will change the behavior of a page, rather than return a value.
  2. Parser functions: all in lowercase. A parser function will be followed by colon and pipe-separated parameters, e.g., {{#ifexpr:Y|Yes|No}}, wrapped in double braces. They will take a value and return a value.
  3. Variables: these are all uppercase, e.g., {{PAGENAME}}. A variable will be wrapped in double braces and will return a value in its place.

The software generally interprets magic words in the following way.

  • Magic words are case sensitive.
  • White space is generously allowed for readability. It will be stripped from the start and end of their keywords and parameters (as is also done inside templates).
  • They can be transcluded, even variables "about the current page". This is ensured by the parsing order.
  • Instead of magically transforming into HTML instructions, <nowiki> tags remove this magic so a magic word can itself be displayed (documented), e.g. <nowiki>{{#magic:}}</nowiki> or {{#magic:<nowiki />}}.

Magic words compared to templates:

  • As with templates, magic words can be transcluded and substituted.
  • The names of magic words are purposely chosen to be unlike the names of templates, and vice versa. Many parser function names will begin with a # (pound), but template names will not start with a #, and probably not end in a : (colon), or be all-uppercase.
  • The first parameter's syntax differs. In {{#magic: p1 | p2 | p3}}, the name is #magic and it is followed by an unspaced : and a required input parameter, p1. With a template, p1 is optional and it is preceded by a | (pipe) instead of a :, e.g. {{template|p1}}.

Behavior switches

Further information: mw:Help:Magic words § Behavior switches
Switch Description
__TOC__ Places the page's table of contents (TOC) at the word's position.
__FORCETOC__ Forces the TOC to appear in its default position. Can be used anywhere on a page.
__NOTOC__ Suppresses the appearance of the page's TOC. Can be used anywhere on a page.
__NOEDITSECTION__ Hides the "edit" links normally beside all headings on the page. To hide the edit link beside a particular heading, specify the heading using e.g. an HTML tag such as <h2>heading</h2> rather than with the usual wiki equals-signs syntax (e.g. == heading == ).
__NEWSECTIONLINK__ On non-talk pages, adds a "New section" link as a means to add a new section to the page.
__NONEWSECTIONLINK__ Removes the "New section" link (the add-new-section link) on talk pages.
__NOGALLERY__ Replaces thumbnails on a category page with normal links.
__HIDDENCAT__ Makes a category hidden when included on that category's page.
__INDEX__ Instructs search engines to index the page.
__NOINDEX__ Instructs search engines not to index the page. See Wikipedia:Controlling search engine indexing.
__STATICREDIRECT__ Prevents the link on a redirection page from being updated automatically when the page to which it redirects is moved (and "Update any redirects that point to the original title" is selected). Also instructs interwiki bots to treat the page as if an article.
__DISAMBIG__ Marks a page as a disambiguation page, adds it to Special:DisambiguationPages and places inward links in Special:DisambiguationPageLinks. (See mw:Extension:Disambiguator.)
{{DISPLAYTITLE:title}} Used to amend the displayed form of the page's title.
{{DEFAULTSORT:sortkey}} Sets the default key (the index) under which the page is categorised.
{{NOEXTERNALLANGLINKS}} (equivalent to {{NOEXTERNALLANGLINKS|*}} ) Suppresses the automated inclusion of Wikidata interlanguage links on the lefthand side of the page. Links to particular rather than all languages may be suppressed by using {{NOEXTERNALLANGLINKS|list}}, where list a pipe-delimited list of language codes (e.g. {{NOEXTERNALLANGLINKS|fr|es|ja}} to suppress the French ("fr"), Spanish ("es") and Japanese ("ja") interlanguage links).

Variables

Shortcut
  • WP:VAR
Further information: mw:Help:Magic words § Variables, and Wikipedia:Page name § sub
Page name variable Output Description
{{FULLPAGENAME}} Help:Magic words Canonical page name. Title line. Title unless letter-case is altered with {{DISPLAYTITLE}}.
{{PAGENAME}} Magic words Title line excluding namespace.
{{BASEPAGENAME}} Magic words Title of parent page, excluding namespace.
{{ROOTPAGENAME}} Magic words Title of topmost parent (before all subpages), excluding namespace.
{{SUBPAGENAME}} Magic words On a subpage, rightmost portion of current title; higher subpagenames show as backlinks.
{{ARTICLEPAGENAME}} Help:Magic words Title of the subject page associated with the current page. These are useful on talk pages (but see note about Category talk pages).
{{SUBJECTPAGENAME}} Help:Magic words
{{TALKPAGENAME}} Help talk:Magic words Title of the talk page associated with the current page. Useful on subject pages.
{{NAMESPACENUMBER}} 12 Number of the current page's namespace.
{{NAMESPACE}} Help Namespace of the title.
{{ARTICLESPACE}} Help On a talk page, the namespace part of the title of the associated subject page.
{{SUBJECTSPACE}} Help
{{TALKSPACE}} Help talk Namespace of the talk page associated with the current page.
{{FULLPAGENAMEE}},
{{PAGENAMEE}},
 (etc.)
Help:Magic_words,
Magic_words,
(etc.)
Adding an E to the end of the above variables, renders the above encoded for use in MediaWiki URLs (i.e. with underscores replacing spaces).
{{SHORTDESC}} Only works on the English Wikipedia, where it displays a short description below the article title on mobile platforms. See Wikipedia:Short description.

Note: The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon (:) is used to pass the parameter, rather than a pipe (|) that is used in templates, like {{MAGICWORD:value}}. For example, {{TALKPAGENAME:Wikipedia:MOS}} returns Wikipedia talk:MOS on any page.

Note: In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require prefixing a colon to avoid unwanted categorization.

For more details on parser functions that relate to page names and namespaces, see: meta:Help:Page name § Variables and parser functions.


Site variable Example Description
{{SITENAME}} Wikipedia
{{SERVER}} //en.wikipedia.org
{{SERVERNAME}} en.wikipedia.org
{{SCRIPTPATH}} /w
{{CURRENTVERSION}} 1.36.0-wmf.31 (142c684) Returns current MediaWiki version.

Other variables by type

Date and time Revision data Statistics
Universal time
  • {{CURRENTYEAR}}
  • {{CURRENTMONTH}}
  • {{CURRENTMONTHNAME}}
  • {{CURRENTMONTHABBREV}}
  • {{CURRENTDAY}}
  • {{CURRENTDAY2}}
  • {{CURRENTDOW}}
  • {{CURRENTDAYNAME}}
  • {{CURRENTTIME}}
  • {{CURRENTHOUR}}
  • {{CURRENTWEEK}}
  • {{CURRENTTIMESTAMP}}
Local website time
  • {{LOCALYEAR}}
  • {{LOCALMONTH}}
  • {{LOCALMONTHNAME}}
  • {{LOCALMONTHABBREV}}
  • {{LOCALDAY}}
  • {{LOCALDAY2}}
  • {{LOCALDOW}}
  • {{LOCALDAYNAME}}
  • {{LOCALTIME}}
  • {{LOCALHOUR}}
  • {{LOCALWEEK}}
  • {{LOCALTIMESTAMP}}
  • {{REVISIONDAY}}
  • {{REVISIONDAY2}}
  • {{REVISIONMONTH}}
  • {{REVISIONYEAR}}
  • {{REVISIONTIMESTAMP}}
  • {{REVISIONUSER}}a
  • {{NUMBEROFPAGES}}
  • {{NUMBEROFARTICLES}}
  • {{NUMBEROFFILES}}
  • {{NUMBEROFEDITS}}
  • {{NUMBEROFUSERS}}
  • {{NUMBEROFADMINS}}
  • {{NUMBEROFACTIVEUSERS}}
a This shows the last user to edit the page. There is no way to show the user viewing the page due to technical restrictions.

Parser functions

Shortcuts
  • WP:PF
  • WP:PARSER
Further information: mw:Help:Magic words § Parser functions, and mw:Help:Extension:ParserFunctions

Metadata

Function Description
{{PAGEID}} Unique page identifier number.
{{PAGESIZE:fullpagename}} Size of named page in bytes.
{{PROTECTIONLEVEL:action|fullpagename}} Protection level assigned to action ("edit", "move", etc.) on named page.
{{PROTECTIONEXPIRY:action|fullpagename}} Protection expiry assigned to action ("edit", "move", etc.) on named page.
{{PENDINGCHANGELEVEL}} Protection level for pending changes on the current page.
{{PAGESINCATEGORY:categoryname}} Number of pages in the category named categoryname. Each subcategory is counted as one item.
{{NUMBERINGROUP:groupname}} Number of users in the user group named groupname.

To output numbers without comma separators (for example, as "123456789" rather than "123,456,789"), append the parameter |R.

Formatting

Further information: mw:Help:Magic words § Formatting
Function Description
{{lc:string}} Converts all characters in string to lower case.
{{lcfirst:string}} Converts first character of string to lower case.
{{uc:string}} Converts all characters in string to upper case.
{{ucfirst:string}} Converts first character of string to upper case.
{{formatnum:unformatted_number}}
{{formatnum:formatted_num |R}}
Adds comma separators to an unformatted_number (e.g. 123456789 becomes 123,456,789). To remove such formatting, use {{formatnum:formatted_number|R}} (i.e. {{formatnum:7,654,321|R}}, for example, produces 7654321).
{{#dateformat:date|format}}
{{#formatdate:date|format}}
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 dmy, mdy, ymd, or ISO 8601 formats, with the user's preference overriding the specified format.
{{padleft:xyz|stringlength}}
{{padright:xyz|stringlength}}

{{padleft:xyz|length|padstr}}
{{padright:xyz|length|padstr}}
Pad with zeroes '0' to the right or left, to fill the given length; an alternative padding string can be given as a third parameter; the repeated padding string (padstr) will be truncated if its length does not evenly divide the required number of characters.
{{plural:N|singular|plural}} Outputs singular if N is equal to 1, otherwise outputs plural. See the documentation at mediawiki.org for more details.
{{#time:format|object}}
{{#timel:format|object}}

{{#time:d F Y|date|langcode}}
Used to format dates and times, for ISO format, dots or English month names. #timel is based on local time as defined for each wiki; for English Wikipedia, this is identical to #time.
The optional 3rd parameter is the output language code (French, German, Swedish: fr, de, sv, etc.). Example Finnish: {{#time:d F Y|June 30, 2016|fi}} shows: 30 kesäkuu 2016 (June). ISO to German: {{#time:d. M Y|1987-10-31|de}} shows: 31. Okt. 1987.
For format codes, see: mw:Help:Extension:ParserFunctions##time. Use the format {{#time: H:i, j F Y (e)|...}} to match the format used by timestamps in signatures.
{{gender:user|m_out|f_out|u_out}} Outputs m_out, f_out or u_out according to whether the gender specified in user 's preferences is, respectively, male, female or unspecified. Other parameter permutations are available, see mw:Help:Magic words#gender and translatewiki:Gender.
{{#tag:tag|content with magic}} Only way to evaluate magic words inside a tag, in order to generate <tag>magic</tag>. Also handles tag attributes.

Paths

Function Description
{{localurl:fullpagename |query}} Relative path to page name. The query parameter is optional.
{{fullurl:fullpagename |query}} Absolute path, without protocol prefix (i.e. without " http: " etc.), to page name. The query parameter is optional.
{{canonicalurl:fullpagename |query}} Absolute path, including protocol prefix, to page name. The query parameter is optional.
{{filepath:filename}} Absolute path to the media file filename.
{{urlencode:string}} Encodes string for use in URL query strings; {{urlencode:test string}}, for example, produces: test+string. To encode string for use in URL paths or MediaWiki page names, append, respectively, |PATH or |WIKI (to produce "test%20string" or "test_string").
{{anchorencode:string}} Input encoded for use in MediaWiki URL section anchors.
{{ns:n}} Returns the name of the namespace whose index is the number n. For MediaWiki URLs, use {{nse:}}.
{{#rel2abs:path}} Converts a relative file path to an absolute path.
{{#titleparts:fullpagename|number|first segment}} Splits the fullpagename (title) into that number of segments.

Conditional

Further information: Help:Conditional expressions
Function Description
{{#expr:expression}} Evaluates expression (see m:Help:Calculation).
{{#if:string |result1 |result2}} Outputs result2 if string is empty, otherwise outputs result1.
{{#ifeq:string1|string2 |result1 |result2}} Outputs result1 if string1 and string2 are equal (alphabetically or numerically), otherwise outputs result2.
{{#iferror:test_string |result1 |result2}} Outputs result1 if test_string generates a parsing error, otherwise outputs result2.
{{#ifexpr:expression |result1 |result2}} Outputs result1 if expression  is true, otherwise outputs result2.
{{#ifexist:pagetitle |result1 |result2}} Outputs result1 if the page [[pagetitle]] exists, otherwise outputs result2. Note that underscores are needed for spaces in namespaces.
{{#switch:string |c1=r1 |c2=r2 ... |default}} Outputs r1 if string is c1, r2 if string is c2, etc., otherwise outputs default (if provided).

If, in these conditional functions, empty unnamed parameters are to be parsed as empty rather than as text (i.e. as empty rather than as the text "{{{1}}}", "{{{2}}}", etc.), they will require trailing pipes (i.e. {{{1|}}}, {{{2|}}}, etc., rather than {{{1}}}, {{{2}}}, etc.).

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

Other

Function Description
{{#babel:code1|code2|...}} Render wp:userboxes telling your language skills. Improves upon {{Babel}} (an alternative).
{{#categorytree:category|...}} List pages in a category, recursively.
{{#coordinates:arg1|arg2|...}} Save the GeoData coordinates of the subject to the page's database. Used in {{coord}}.
{{#invoke:module|function|arg1|...}} Use Scribunto to transclude a lua template, e.g. function replace in module String.
{{#language:code1|code2}} Print the name represented by the language code, e.g. en → English. Print in language 2 if given.
{{#lst:}} {{#lsth:}} {{#lstx:}} Three ways to transclude a section of a page.
{{#property:arg1|arg2|...}} Include a property (Wikidata) from a named entity, instead of the default on the page.
{{#related:...}} Links to similar topics, to engage readers. (Beta feature.)
{{#section:}}​{{#section-h:}}​{{#section-x:}} Aliases for {{#lst:}} {{#lsth}} {{#lstx}} (above).
{{#statements:arg1|...}} Display the value of any statement included in an item.
{{#target:fullpagename}} Send a message to a list of talk pages on the fullpagename, using the MassMessage function.
{{int:pagename}} Transclude an interface message, i.e. a pagename in MediaWiki namespace

See also

  • Help:Magic links for ISBN, PMID, and RFC (all deprecated)
  • mw:Localisation
  • mw:Manual:Extending wiki markup
  • CoreParserFunctions.php
  • wikEd, a MediaWiki editor with syntax highlighting for templates and parser functions
  • Preferences → Gadgets → Editing → check Syntax highlighter
  • Preferences → Beta features → check Wiki syntax highlighting
  • Special:Version, see last section "Parser function hooks": a list that should include all of the magic words on this page
  • {{Ifexist not redirect}}, works with the {{#ifexist:}} expression while allowing redirects to be identified and parsed differently
Wikipedia technical help
Get personal technical help at the Teahouse, Help desk, Village pump (technical), talk pages or IRC.
General technical
help
  • Browser notes
    • Bypass cache
    • Keyboard shortcuts
    • Troubleshooting
  • Editing
    • CharInsert
    • Edit conflict
    • Edit toolbar
    • Reverting
  • How to create a page
  • IRC
    • Tutorial
  • Mobile access
  • Multilingual support
  • Page history
  • Page information
  • Page name
    • Help
  • Printing
  • Software notices
    • Editnotice
  • Special Characters
    • Entering
  • User access levels
  • VisualEditor
    • User guide
Special page-related
  • Special page help
  • Edit filter
  • Emailing users
  • Logging in
    • Reset passwords
  • Logs
  • Moving a page
    • Fixing cut-and-paste moves
  • Notifications/Echo
    • FAQ
  • Page Curation
  • Page import
  • Pending changes
  • Random pages
  • Recent changes
  • Related changes
  • Searching
    • Linksearch
  • Tags
  • User contributions
  • Watchlist
  • What links here
Wikitext
  • Wikitext
    • Cheatsheet
  • Columns
  • Line-break handling
  • Lists
  • Magic words
    • For beginners
    • Conditional expressions
    • Switch parser function
    • Time function
  • Redirects
  • Sections and TOCs
  • Tables
    • Introduction
    • Basics
    • Advanced table formatting
    • Collapsing
    • Conditional tables
    • Sorting
  • Using colours
Links and diffs
  • Links
    • Interlanguage
    • Interwiki
    • Permanent
  • Diffs
    • Simplest diff guide
    • Simple diff and link guide
    • Complete diff and link guide
  • Colon trick
  • Link color
  • Magic links
  • Pipe trick
  • URLs
Media files: images,
videos and sounds
  • Media help
  • Files
    • Creation and usage
    • Moving files to Commons
  • Images
    • Introduction to images
    • Picture tutorial
    • Preparing images for upload
    • Uploading images
    • Options to hide an image
    • Extended image syntax
    • SVG help
  • Gallery tag
  • Graphics tutorials
    • Basic bitmap image editing
    • How to improve image quality
    • Graphics Lab resources
  • Sound file markup
  • Visual file markup
Other graphics
  • Family trees
  • Graphs and charts
    • How to create
    • Barcharts
    • To scale charts
  • Math formulas
    • Math symbols
    • LaTeX symbols
    • Rendering math
  • Musical scores
    • Musical symbols
  • Timeline
    • EasyTimeline syntax
  • WikiHiero syntax
Templates and
Lua modules
  • Templates
  • Advanced template coding
  • Template documentation
  • Template index
  • Template limits
  • Template sandbox and test cases
  • Citation templates
  • Lua help
  • Lua project
    • Resources
    • To do
  • Substitution
  • Purge
    • Job queue
  • Transclusion
    • Labeled section
  • Guide to Scribbling
Data structure
  • Namespaces
  • Main/Article
  • Category
  • Draft
  • File
    • File description page
  • Help
  • Portal
  • Project/Wikipedia
  • Talk
    • Archiving
  • Template
  • User
    • User page design
  • MediaWiki
    • Bug reports and feature requests
    • System message
    • TimedMediaHandler extension
  • Module
  • Special
HTML and CSS
  • Cascading Style Sheets
  • HTML in wikitext
  • Catalogue of CSS classes
  • Common.js and common.css
  • User CSS for monospaced coding font
  • Classes in Ambox
  • Classes in microformats
  • Markup validation
  • Span tags
  • Useful styles
Customisation and tools
  • Preferences
  • Gadgets
  • Skins
  • Citation tools
  • Cleaning up vandalism tools
  • Customizing watchlists
    • Hide pages
  • IRC Scripts
  • User scripts
    • Guide
    • Techniques
  • User style
  • Tools
    • Alternative browsing
    • Browser tools
    • Editing tools
    • Navigation shortcuts
    • Optimum tool set
  • Wikimedia Cloud Services
  • Beta Features at MediaWiki
Automated editing
  • AfC helper script
  • AutoWikiBrowser
  • Bots
    • Creating
  • HotCat
  • Huggle
  • Navigation popups
  • RedWarn
  • Twinkle
  • WPCleaner
  • Inactive
    • igloo
    • STiki
  • See also: Category:Wikipedia how-to
  • Category:Wikipedia information pages
    Further navigation at: Help pages
    • Administrators
  • Accessibility
  • Accounts
  • Bots
  • Referencing
    • Citation metadata
  • Templates
  • User scripts
source: https://en.wikipedia.org/wiki/Help:Magic_words
  • This page was last edited on 22 February 2021, at 11:13 (UTC).
  • Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.
  • Privacy policy
  • About Wikipedia
  • Disclaimers
  • Contact Wikipedia
  • Mobile view
  • Developers
  • Statistics
  • Cookie statement
  • Wikimedia Foundation
  • Powered by MediaWiki

Please consider signing this Petition to Educate the DEA and UN on the medical benefits of Cannabis.

State Resources

  • Texas

    Texas

    January 22, 2018
  • Repetitive Transcranial Magnetic Stimulation | rTMS | Depression Therapy for Veterans at the Waco, Tx. VA

    Repetitive Transcranial Magnetic Stimulation | rTMS | Depression Therapy for Veterans at the Waco, Tx. VA

    February 22, 2019
  • San Diego Vet Centers

    San Diego Vet Centers

    January 22, 2018

Resources

  • VA Administration Sets National Policy Allowing Robotic Prosthetics

    VA Administration Sets National Policy Allowing Robotic Prosthetics

    December 26, 2015
  • VA benefits for Veterans of the Armed Forces of the United States of America

    VA benefits for Veterans of the Armed Forces of the United States of America

    March 18, 2016
  • Human Tissue Regeneration with Pigs Bladder Powder

    Human Tissue Regeneration with Pigs Bladder Powder

    March 18, 2016

Latest Posts

  • The American Legion Urge the Drug Enforcement Agency to License Privately-Funded Medical Marijuana Production Operations in the United States

    The American Legion Urge the Drug Enforcement Agency to License Privately-Funded Medical Marijuana Production Operations in the United States

    September 11, 2016
  • Compassionate Care Act of 2015 in Texas Discriminates Against Veterans

    Compassionate Care Act of 2015 in Texas Discriminates Against Veterans

    March 27, 2016
  • National Second Opinion Day 4/20/16 - All Veterans Ask VA for Second Opinion

    National Second Opinion Day 4/20/16 – All Veterans Ask VA for Second Opinion

    March 18, 2019

FOIA Contacts

  • Veterans Affairs | Veteran Claims File Request

  • Postal Inspection Service

  • USPS Field Office

Copyright © 2021 Good Acts.

Omega WordPress Theme by ThemeHall