Difference between revisions of "Help:Template"

From ArchWiki
Jump to: navigation, search
(update interlanguage links)
(Tag: wiki-scripts)
 
(72 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 
[[Category:Help]]
 
[[Category:Help]]
 +
[[el:Help:Template]]
 
[[es:Help:Template]]
 
[[es:Help:Template]]
[[zh-CN:Help:Template]]
+
[[fa:راهنما:الگو]]
 +
[[ja:ヘルプ:テンプレート]]
 +
[[pt:Help:Template]]
 +
[[ru:Help:Template]]
 +
[[zh-hans:Help:Template]]
 +
[[zh-hant:Help:Template]]
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|Help:Editing}}
 
{{Related|Help:Editing}}
Line 10: Line 16:
 
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.
  
==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 30:
 
{{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:
Line 34: Line 40:
 
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:
+
{{Tip|The pipe symbol "{{!}}" can be escaped using the {{ic|<nowiki>{{!}}</nowiki>}} [[MW:Help:Magic_words#Other|magic word]].}}
{{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:
+
==== Named and numbered parameters ====
{{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==
+
If the problem is only with "=" signs, the recommended solution is to explicitly introduce template parameters with their positional numbers or names.
 +
 
 +
Example: {{ic|<nowiki>{{Tip|1=https://www.archlinux.org/?foo=bar}}</nowiki>}}
 +
 
 +
Result: {{Tip|1=https://www.archlinux.org/?foo=bar}}
 +
 
 +
This is very useful for:
 +
 
 +
* Variable definitions.
 +
 
 +
* [[Help:Editing#External_links|External links]] with query strings in URLs.
 +
 
 +
* Shell strings and commands.
 +
 
 +
* Lines of code.
 +
 
 +
===== Multiple parameters =====
 +
 
 +
* Using positional parameters {{ic|1}} and {{ic|2}}
 +
 
 +
<nowiki>{{hc|1=$ echo "="|2==}}</nowiki>
 +
 
 +
Result:  {{hc|1=$ echo "="|2==}}
 +
 
 +
* Using named parameters {{ic|head}} and {{ic|output}}
 +
 
 +
<nowiki>{{hc|head=$ echo "="|output==}}</nowiki>
 +
 
 +
Result:  {{hc|head=$ echo "="|output==}}
 +
 
 +
==== 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:
 
The following template should be used when creating new templates to facilitate usage and editing:
  
{{bc|<nowiki><noinclude>{{Template}}
+
<nowiki><noinclude>
 +
{{Template}}
  
'''A brief description of the template'''
+
A brief description of the template
  
====Usage====
+
== Usage ==
  
{{ic|&lt;nowiki&gt;{{Template Name|param1|param2|...|paramN}}&lt;/nowiki&gt;}}
+
&lt;nowiki&gt;{{Template name|param1|param2|...|paramN}}&lt;/nowiki&gt;
  
====Example====
+
== Example ==
  
{{Template Name|param1|param2|...|paramN}}</noinclude><includeonly>Template code goes here...</includeonly></nowiki>}}
+
{{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]].
+
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 ==
 
== 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]].
 
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]].
  
===Sandbox===
+
{{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.}}
  
{{Warning|Please do not experiment with existing templates. If you want to edit a template, copy the text to [[Template:Sandbox]], edit and test it there, and copy it back when it works.}}
+
=== Testing ===
  
 
* [[Template:Sandbox]]
 
* [[Template:Sandbox]]
 +
* [[Template:Lorem Ipsum]]
  
===Protected templates===
+
=== Article status templates ===
 
 
These templates are widely used and are thus protected against editing. Please feel free to use them where applicable or suggest modifications on discussion pages.
 
 
 
====Article status templates====
 
  
 
* [[Template:Accuracy]]
 
* [[Template:Accuracy]]
 +
* [[Template:Archive]]
 
* [[Template:Bad translation]]
 
* [[Template:Bad translation]]
* [[Template:Deletion]]
 
 
* [[Template:Expansion]]
 
* [[Template:Expansion]]
 +
* [[Template:Laptop style]]
 
* [[Template:Merge]]
 
* [[Template:Merge]]
* [[Template:Moveto]]
+
* [[Template:Move]]
 
* [[Template:Out of date]]
 
* [[Template:Out of date]]
* [[Template:Poor writing]]
+
* [[Template:Redirect]]
* [[Template:Stub]]
+
* [[Template:Remove]]
 +
* [[Template:Style]]
 
* [[Template:Translateme]]
 
* [[Template:Translateme]]
  
====Related articles templates====
+
=== Related articles templates ===
  
 
* [[Template:Related articles start]]
 
* [[Template:Related articles start]]
Line 110: Line 167:
 
* [[Template:Related articles end]]
 
* [[Template:Related articles end]]
  
===Unprotected templates===
+
=== Code formatting templates ===
 
 
====Code formatting templates====
 
  
 
* [[Template:ic]]
 
* [[Template:ic]]
Line 118: Line 173:
 
* [[Template:hc]]
 
* [[Template:hc]]
  
====Box templates====
+
=== Note templates ===
  
* [[Template:FAQ]]
 
* [[Template:News]]
 
 
* [[Template:Note]]
 
* [[Template:Note]]
 
* [[Template:Tip]]
 
* [[Template:Tip]]
 
* [[Template:Warning]]
 
* [[Template:Warning]]
  
====Interwiki templates====
+
=== Miscellaneous templates ===
 
 
* [[Template:Wikipedia]]
 
 
 
====Miscellaneous templates====
 
  
 
* [[Template:App]]
 
* [[Template:App]]
 +
* [[Template:Broken package link]]
 
* [[Template:Bug]]
 
* [[Template:Bug]]
* [[Template:Linkrot]]
+
* [[Template:Dead link]]
* [[Template:Lorem Ipsum]]
+
* [[Template:Lowercase title]]
 +
* [[Template:man]]
 +
* [[Template:Unsigned]]
  
====Package templates====
+
=== Package templates ===
  
 
* [[Template:Pkg]]
 
* [[Template:Pkg]]
Line 143: Line 195:
 
* [[Template:AUR]]
 
* [[Template:AUR]]
  
==See also==
+
=== Table templates ===
*[[Template:Template]]
+
 
*http://meta.wikimedia.org/wiki/Help:Template
+
* [[Template:R]]
 +
* [[Template:G]]
 +
* [[Template:B]]
 +
* [[Template:C]]
 +
* [[Template:M]]
 +
* [[Template:Y]]
 +
* [[Template:Grey]]
 +
* [[Template:Yes]]
 +
* [[Template:No]]
 +
 
 +
== See also ==
 +
 
 +
* [[Template:Template]]
 +
* [[MetaWikimedia: Help:Template]]

Latest revision as of 19:31, 18 August 2017

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.

Tip: The pipe symbol "|" can be escaped using the {{!}} magic word.

Named and numbered parameters

If the problem is only with "=" signs, the recommended solution is to explicitly introduce template parameters with their positional numbers or names.

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

Result:
Tip: https://www.archlinux.org/?foo=bar

This is very useful for:

  • Variable definitions.
  • Shell strings and commands.
  • Lines of code.
Multiple parameters
  • Using positional parameters 1 and 2
{{hc|1=$ echo "="|2==}}
Result:
$ echo "="
=
  • Using named parameters head and output
{{hc|head=$ echo "="|output==}}
Result:
$ 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}}}}
Tip: = | }} https://www.archlinux.org/ 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