Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Help:Template
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===General=== Using a template is similar to calling a [[Function (computer programming)|function]] in programming. When called, it returns a value. For a template, calling is known as a ''template call'' and the return value is known as the ''expansion'' of the template, which is treated as part of the calling page's source. Like functions, some templates can take parameters that affect their output. Calling a template causes it to be either ''transcluded'' or ''substituted'' in the page that calls it (the ''target page''). [[Wikipedia:Transclusion|Transcluding]] a template means that when MediaWiki <em>displays</em> the page, it treats the template as if it were directly in the pageβs source. [[Substitutionary atonement|Substituting]] a template differs in that it inserts the content of the template permanently into the target page when it is <em>saved</em> and subsequent editors cannot tell that it originated from a template. When you update a template, every page that transcludes it automatically reflects the update when the page is displayed in the future, whereas updating a template has no effect on pages that have previously been saved with the template substituted. To transclude a template, insert {{tnull|{{var|Template name}}}} at the point where it should appear in the page source. To substitute it, use {{tnull|subst:{{var|Template name}}}}. This wikitext is called a ''template call''. In [[MediaWiki]], the [[wiki software]] that Wikipedia uses, [[Help:Magic words#Variables|variables]] are distinct from templates, though both are referenced by double [[Curly brackets|curly braces]] <code>{{ }}</code> and they both return a value. These references differ in that variables in MediaWiki are always uppercase, while template names follow the same conventions and have the same [[WP:NCHASHTAG|limitations]] as [[Help:Page names|page names]]. For example, they are [[Case sensitivity|case-sensitive]] (except for the first character), [[underscore]]s are parsed as spaces, and template names cannot contain the characters <code><nowiki># < > [ ] | { }</nowiki></code> because they are reserved for [[wiki markup]]. The [[number sign]] <code>#</code> is used as a [[URI fragment|fragment identifier]], which identifies a {{em|fragment}} or [[Help:Section|section]] of a page. Although you can use it in a [[WP:LINK|link]] to link to a section of a template page (e.g., [[Template:Portal#Example]]), fragment identifiers have no meaning in a template call and are ignored. For example, {{tnull|Portal{{var|#Location}}|Books}} is the same as {{tnull|Portal|Books}}. The template namespace is the default, so you can leave out the namespace <code>Template:</code> in the template name, and it is conventional to do so. However, you must specify the namespace prefix for templates in other namespaces, such as <code>User:</code>. To transclude a page in [[WP:MAINSPACE|mainspace]], precede its page name with a colon, as <code>{<nowiki />{:{{var|Page name}}}}</code>. {{A note}} Attempting to transclude a template that does not exist produces a [[WP:Red link|red link]], just like linking to any other nonexistent page. Following the link allows one to create that particular template. It is not possible to transclude templates between projects (such as different-language Wikipedias or MediaWiki) β to use a template on another language project, a copy of the template must be created in that project.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)