Difference between revisions of "Help:Template"

From ArchWiki
Jump to: navigation, search
m (Frequently used templates: add link to Category:Template)
(Template:Stub is deprecated)
 
(52 intermediate revisions by 13 users not shown)
Line 1: Line 1:
 
[[Category:Help]]
 
[[Category:Help]]
 
[[es:Help:Template]]
 
[[es:Help:Template]]
 +
[[fa:راهنما:الگو]]
 +
[[ja:ヘルプ:テンプレート]]
 +
[[ru:Help:Template]]
 
[[zh-CN:Help:Template]]
 
[[zh-CN:Help:Template]]
{{Article summary start}}
+
[[zh-TW:Help:Template]]
{{Article summary text|A basic introduction to using and creating templates.}}
+
{{Related articles start}}
{{Article summary end}}
+
{{Related|Help:Editing}}
 +
{{Related|Help:Reading}}
 +
{{Related|Help:Style}}
 +
{{Related articles end}}
  
 
A template is a piece of predefined [[Wikipedia:Wikitext|wikitext]] that can be inserted into an article. Templates are primarily used to aid in formatting content.
 
A template is a piece of predefined [[Wikipedia:Wikitext|wikitext]] that can be inserted into an article. Templates are primarily used to aid in formatting content.
  
Visit [[:Category:Template]] for a listing of all available templates.
+
== Usage ==
 
+
==Usage==
+
  
 
Templates are used by adding the following markup to an article:
 
Templates are used by adding the following markup to an article:
  
{{bc|<nowiki>{{Template Name}}</nowiki>}}
+
<nowiki>{{Template name}}</nowiki>
  
Most templates take additional arguments, such as [[:Template:Note]]:
+
Most templates take additional arguments, such as [[Template:Note]]:
  
{{bc|<nowiki>{{Note|This text should be noted.}}</nowiki>}}
+
<nowiki>{{Note|This text should be noted.}}</nowiki>
  
 
which produces:
 
which produces:
Line 24: Line 28:
 
{{Note|This text should be noted.}}
 
{{Note|This text should be noted.}}
  
Some templates use named parameters, such as [[:Template:Hc]]:
+
Some templates use named parameters, such as [[Template:hc]]:
  
{{bc|<nowiki>{{Hc|head=/etc/rc.local|output=exit 0}}</nowiki>}}
+
<nowiki>{{hc|head=/etc/rc.local|output=exit 0}}</nowiki>
  
 
which produces:
 
which produces:
  
{{Hc|head=/etc/rc.local|output=exit 0}}
+
{{hc|head=/etc/rc.local|output=exit 0}}
  
 
The general format is:
 
The general format is:
  
{{bc|<nowiki>{{Template Name|param1|param2|...|paramN}}</nowiki>}}
+
<nowiki>{{Template name|param1|param2|...|paramN}}</nowiki>
  
See each templates' page for specific usage instructions.
+
See each template's page for specific usage instructions.
  
===Escape template-breaking characters===
+
=== Style ===
  
There are some characters that, if used inside a template, will break its output: most frequently this happens with {{ic|1==}} (the equal sign) and {{ic|<nowiki>|</nowiki>}} (the pipe sign).
+
* Templates should be used with the capitalization shown in the examples in their pages, for example {{ic|&#123;{Pkg&#124;...}} and {{ic|&#123;{ic&#124;...}} are correct, while {{ic|&#123;{pkg&#124;...}} and {{ic|&#123;{Ic&#124;...}} are not.
 +
* There should be no spaces around the template name: {{ic|&#123;{Template name&#124;...}} is correct, while for example {{ic|&#123;{ Template name &#124;...}} is not.
 +
* Templates should not be categorized.
  
The easiest and most effective solutions to this problem are:
+
=== Escape template-breaking characters ===
  
*Using numbered parameters like in:
+
There are some characters that, if used inside a template, will break its output: most frequently this happens with "=" (the equal sign) and "|" (the pipe sign). Solutions to this problem are described below.
{{Note|1=This method is effective only with = and is very useful with query strings in URLs, e.g. https://www.archlinux.org/?foo=bar}}
+
{{bc|<nowiki>{{Note|1=This method is effective only with = and is very useful with query strings in URLs, e.g. https://www.archlinux.org/?foo=bar}}</nowiki>}}
+
  
*Replacing the offending characters with their respective HTML entities, like in:
+
==== Named parameters ====
{{Note|This method supports all kinds of characters, including &#61;, &#124; and &#125;&#125; ( https://www.archlinux.org/?foo&#61;bar )}}
+
{{bc|<nowiki>{{Note|This method supports all kinds of characters, including &amp;#61;, &amp;#124; and &amp;#125;&amp;#125; ( https://www.archlinux.org/?foo&amp;#61;bar )}}</nowiki>}}
+
  
*Enclosing the offending characters in <nowiki><nowiki></nowiki> tags, like in:
+
If the problem is only with "=" signs, the recommended solution is to explicitly introduce template parameters with their names or positional numbers. This is very useful for variable definitions or [[Help:Editing#External_links|external links]] with query strings in URLs, but will not work for other offending characters, like "|". For example:
{{Note|<nowiki>This method displays all kinds of characters ( = | }} ), but completely prevents the wiki engine from processing text markup, like links ( https://www.archlinux.org/ ) and other templates ( {{ic|foo}} ).</nowiki>}}
+
{{bc|<nowiki>{{Note|<nowiki>This method displays all kinds of characters ( = | }} ), but completely prevents the wiki engine from processing text markup, like links ( https://www.archlinux.org/ ) and other templates ( {{ic|foo}} ).&lt;/nowiki>}}</nowiki>}}
+
  
==Creation==
+
<nowiki>{{Tip|1=https://www.archlinux.org/?foo=bar}}</nowiki>
 +
 
 +
{{Tip|1=https://www.archlinux.org/?foo=bar}}
 +
 
 +
Or, with multiple parameters:
 +
 
 +
<nowiki>{{hc|1=$ echo "="|2==}}</nowiki>
 +
 
 +
<nowiki>{{hc|head=$ echo "="|output==}}</nowiki>
 +
 
 +
{{hc|1=$ echo "="|2==}}
 +
 
 +
==== nowiki tags ====
 +
 
 +
If you are having problems with characters other than "=", e.g. "|", the recommended solution is to enclose the whole parameter in {{ic|<nowiki><nowiki></nowiki>}} tags. This method displays all kinds of characters, but completely prevents the wiki engine from processing text markup, such as links and other templates. For example:
 +
 
 +
<nowiki>{{Tip|&lt;nowiki>= | }} https://www.archlinux.org/ {{ic|foo}}&lt;/nowiki>}}</nowiki>
 +
 
 +
{{Tip|<nowiki>= | }} https://www.archlinux.org/ {{ic|foo}}</nowiki>}}
 +
 
 +
Enclosing only specific parts (or even single characters) in {{ic|<nowiki><nowiki></nowiki>}} tags still works of course, but for readability it is recommended to use such method only if links or other templates have to be normally displayed. For example:
 +
 
 +
<nowiki>{{Tip|&lt;nowiki>= | }}&lt;/nowiki> https://www.archlinux.org/ {{ic|foo}}}}</nowiki>
 +
 
 +
{{Tip|<nowiki>= | }}</nowiki> https://www.archlinux.org/ {{ic|foo}}}}
 +
 
 +
==== HTML entities ====
 +
 
 +
Replacing the offending characters with their respective HTML entities always works, but since it reduces the readability of the source text, it is recommended only when the solutions above are not practicable. For example:
 +
 
 +
<nowiki>{{Tip|&amp;#61; &amp;#124; &amp;#125;&amp;#125;}}</nowiki>
 +
 
 +
{{Tip|&#61; &#124; &#125;&#125;}}
 +
 
 +
== Creation ==
  
 
{{Note|
 
{{Note|
*Only create relevant templates. If you are attempting to create a very specialized template that will likely only ever be used on a few articles, please do not bother, avoid cluttering up the templates namespace.
+
* Before creating a template, discuss the idea in [[Help talk:Template]].
*Only create concise templates. Remember [[The Arch Way]]: Keep It Simple, Stupid!}}
+
* Only create relevant templates. If you are attempting to create a very specialized template that will likely only ever be used on a few articles, please do not bother, avoid cluttering up the templates namespace.
 +
* Only create concise templates. Remember [[The Arch Way]]: Keep It Simple, Stupid!
 +
}}
 +
 
 +
The following template should be used when creating new templates to facilitate usage and editing:
 +
 
 +
<nowiki><noinclude>
 +
{{Template}}
 +
 
 +
A brief description of the template
 +
 
 +
== Usage ==
 +
 
 +
&lt;nowiki&gt;{{Template name|param1|param2|...|paramN}}&lt;/nowiki&gt;
 +
 
 +
== Example ==
 +
 
 +
{{Template name|param1|param2|...|paramN}}</noinclude><includeonly>Template code goes here...</includeonly></nowiki>
 +
 
 +
To begin the creation process, simply visit [[:Template:Template name]] (substituting {{ic|Template name}} with the desired name of the template), [[Help:Editing|edit, and add the relevant wikitext]].
 +
 
 +
== List of templates ==
 +
 
 +
The templates that users can use directly in articles on the ArchWiki are listed below. Click on the links to see their detailed usage. For a list that also includes localizations and meta templates see [[Special:AllPages/Template:]], [[Special:PrefixIndex/Template:]] or [[Special:MostLinkedTemplates]].
 +
 
 +
{{Warning|Please do not experiment with existing templates. If you want to edit a non-protected template, copy the text to [[Template:Sandbox]], edit and test it there, and copy it back when it works. It is strongly recommended (and necessary for protected templates) to suggest any modifications on discussion pages first.}}
 +
 
 +
=== Testing ===
 +
 
 +
* [[Template:Sandbox]]
 +
* [[Template:Lorem Ipsum]]
 +
 
 +
=== Article status templates ===
 +
 
 +
* [[Template:Accuracy]]
 +
* [[Template:Archive]]
 +
* [[Template:Bad translation]]
 +
* [[Template:Expansion]]
 +
* [[Template:Laptop style]]
 +
* [[Template:Merge]]
 +
* [[Template:Move]]
 +
* [[Template:Out of date]]
 +
* [[Template:Redirect]]
 +
* [[Template:Remove]]
 +
* [[Template:Style]]
 +
* [[Template:Translateme]]
 +
 
 +
=== Related articles templates ===
  
The following template should be used when creating new templates to ensure that the template is a member of [[:Category:Template]] and to facilitate usage and editing:
+
* [[Template:Related articles start]]
 +
* [[Template:Related]]
 +
* [[Template:Related articles end]]
  
{{bc|<nowiki><noinclude>{{Template}}
+
=== Code formatting templates ===
  
'''A brief description of the template'''
+
* [[Template:ic]]
 +
* [[Template:bc]]
 +
* [[Template:hc]]
  
====Usage====
+
=== Note templates ===
  
{{ic|&lt;nowiki&gt;{{Template Name|param1|param2|...|paramN}}&lt;/nowiki&gt;}}
+
* [[Template:Note]]
 +
* [[Template:Tip]]
 +
* [[Template:Warning]]
  
====Example====
+
=== Miscellaneous templates ===
  
{{Template Name|param1|param2|...|paramN}}</noinclude><includeonly>Template code goes here...</includeonly></nowiki>}}
+
* [[Template:App]]
 +
* [[Template:Bug]]
 +
* [[Template:Dead link]]
 +
* [[Template:Broken package link]]
 +
* [[Template:Unsigned]]
  
To begin the creation process, simply visit [[:Template:Template Name]] (substituting {{ic|Template Name}} with the desired name of the template), [[Help:Editing|edit, and add the relevant wikitext]].
+
=== Package templates ===
  
== Frequently used templates ==
+
* [[Template:Pkg]]
Some of the templates most frequently used on the Arch Wiki are listed below. Click on the links to see their detailed usage. For a complete list see [[Special:MostLinkedTemplates]], for a list of all Templates see [http://wiki.archlinux.org/index.php/Category:Template Category:Template].
+
* [[Template:Grp]]
 +
* [[Template:AUR]]
  
=== Text boxes ===
+
=== Table templates ===
* [[Template:Note|<nowiki>{{Note|This text should be noted.}}</nowiki>]]
+
* [[Template:Warning|<nowiki>{{Warning|This text should be heeded.}}</nowiki>]]
+
* [[Template:Tip|<nowiki>{{Tip|This text should be considered.}}</nowiki>]]
+
  
=== Code formatting ===
+
* [[Template:R]]
* [[Template:ic|<nowiki>{{ic|Inline code}}</nowiki>]]
+
* [[Template:G]]
* [[Template:bc|<nowiki>{{bc|Block code without header}}</nowiki>]]
+
* [[Template:B]]
* [[Template:hc|<nowiki>{{hc|Block code with header}}</nowiki>]]
+
* [[Template:C]]
* [[Template:Keypress|<nowiki>{{Keypress|Ctrl+Alt+Del}}</nowiki>]]
+
* [[Template:M]]
 +
* [[Template:Y]]
 +
* [[Template:Yes]]
 +
* [[Template:No]]
  
=== Other ===
+
== See also ==
* [[Template:Pkg|<nowiki>{{Pkg|package}}</nowiki>]]
+
* [[Template:AUR|<nowiki>{{AUR|package}}</nowiki>]]
+
* [[Template:Linkrot|<nowiki>{{Linkrot|yyyy|mm|dd}}</nowiki>]]
+
  
==See also==
+
* [[Template:Template]]
*[[Template:Template]]
+
* http://meta.wikimedia.org/wiki/Help:Template
*http://meta.wikimedia.org/wiki/Help:Template
+
*[[Help:Style]]
+

Latest revision as of 10:09, 7 February 2016

A template is a piece of predefined wikitext that can be inserted into an article. Templates are primarily used to aid in formatting content.

Usage

Templates are used by adding the following markup to an article:

{{Template name}}

Most templates take additional arguments, such as Template:Note:

{{Note|This text should be noted.}}

which produces:

Note: This text should be noted.

Some templates use named parameters, such as Template:hc:

{{hc|head=/etc/rc.local|output=exit 0}}

which produces:

/etc/rc.local
exit 0

The general format is:

{{Template name|param1|param2|...|paramN}}

See each template's page for specific usage instructions.

Style

  • Templates should be used with the capitalization shown in the examples in their pages, for example {{Pkg|... and {{ic|... are correct, while {{pkg|... and {{Ic|... are not.
  • There should be no spaces around the template name: {{Template name|... is correct, while for example {{ Template name |... is not.
  • Templates should not be categorized.

Escape template-breaking characters

There are some characters that, if used inside a template, will break its output: most frequently this happens with "=" (the equal sign) and "|" (the pipe sign). Solutions to this problem are described below.

Named parameters

If the problem is only with "=" signs, the recommended solution is to explicitly introduce template parameters with their names or positional numbers. This is very useful for variable definitions or external links with query strings in URLs, but will not work for other offending characters, like "|". For example:

{{Tip|1=https://www.archlinux.org/?foo=bar}}

Or, with multiple parameters:

{{hc|1=$ echo "="|2==}}
{{hc|head=$ echo "="|output==}}
$ echo "="
=

nowiki tags

If you are having problems with characters other than "=", e.g. "|", the recommended solution is to enclose the whole parameter in <nowiki> tags. This method displays all kinds of characters, but completely prevents the wiki engine from processing text markup, such as links and other templates. For example:

{{Tip|<nowiki>= | }} https://www.archlinux.org/ {{ic|foo}}</nowiki>}}
Tip: = | }} https://www.archlinux.org/ {{ic|foo}}

Enclosing only specific parts (or even single characters) in <nowiki> tags still works of course, but for readability it is recommended to use such method only if links or other templates have to be normally displayed. For example:

{{Tip|<nowiki>= | }}</nowiki> https://www.archlinux.org/ {{ic|foo}}}}

HTML entities

Replacing the offending characters with their respective HTML entities always works, but since it reduces the readability of the source text, it is recommended only when the solutions above are not practicable. For example:

{{Tip|&#61; &#124; &#125;&#125;}}
Tip: = | }}

Creation

Note:
  • Before creating a template, discuss the idea in Help talk:Template.
  • Only create relevant templates. If you are attempting to create a very specialized template that will likely only ever be used on a few articles, please do not bother, avoid cluttering up the templates namespace.
  • Only create concise templates. Remember The Arch Way: Keep It Simple, Stupid!

The following template should be used when creating new templates to facilitate usage and editing:

<noinclude>
{{Template}}

A brief description of the template

== Usage ==

<nowiki>{{Template name|param1|param2|...|paramN}}</nowiki>

== Example ==

{{Template name|param1|param2|...|paramN}}</noinclude><includeonly>Template code goes here...</includeonly>

To begin the creation process, simply visit Template:Template name (substituting Template name with the desired name of the template), edit, and add the relevant wikitext.

List of templates

The templates that users can use directly in articles on the ArchWiki are listed below. Click on the links to see their detailed usage. For a list that also includes localizations and meta templates see Special:AllPages/Template:, Special:PrefixIndex/Template: or Special:MostLinkedTemplates.

Warning: Please do not experiment with existing templates. If you want to edit a non-protected template, copy the text to Template:Sandbox, edit and test it there, and copy it back when it works. It is strongly recommended (and necessary for protected templates) to suggest any modifications on discussion pages first.

Testing

Article status templates

Related articles templates

Code formatting templates

Note templates

Miscellaneous templates

Package templates

Table templates

See also