Help:Template

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 and are not.
  • There should be no spaces around the template name: is correct, while for example 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 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:

Result:

This is very useful for:

  • Variable definitions.
  • External links with query strings in URLs.
  • Shell strings and commands.
  • Lines of code.

White space characters (i.e. newlines) are automatically stripped from the beginnings and ends of named parameter values. To preserve white space characters, start the parameter value with a <nowiki/> tag.

Example:

Result:

Multiple parameters
  • Using positional parameters and
{{hc|1=$ echo "="|2==}}

Result:

  • Using named parameters and
{{hc|head=$ echo "="|output==}}

Result:

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://archlinux.org/ {{ic|foo}}</nowiki>}}
Tip: = | }} https://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://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; &#123;&#123; &#125;&#125;}}

Creation

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 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.

Testing

  • Template:Sandbox
  • Template:Lorem Ipsum

Article status templates

These templates should be added at the beginning of concerning articles or sections. See also Help:Style#Article status templates.

Translators should also check template guidelines in ArchWiki:Translation Team.

The pages flagged with the article status templates are tracked in the corresponding maintenance category and in ArchWiki:Statistics#Maintenance statistics.

NameRecommended useParameters
Template:StyleContent with language, wiki syntax or style issues. — reason, — optional talk page, — optional section in the default talk page
Template:AccuracyIncorrect, misleading or confusing content.
Template:ExpansionIncomplete content.
Template:Out of dateOutdated content.
Template:RemoveIrrelevant or unhelpful content.
Template:ArchiveObsolete pages.
Template:Laptop styleLaptop pages not following the Laptop page guidelines.
Template:TranslatemeIncomplete translations.
Template:Bad translationProblematic translations.
Template:TranslationStatusStatus of translations. — original title, — translation date, — revision number
Template:MergeContent overlaps with another article. — target page, — reason, — optional talk page, — optional section in the default talk page
Template:MoveRename page, move section to another article.
Template:RedirectRedirect page to another article.
Template:UnsupportedUser pages unsupported by Arch Linux. — date of last review by page author
  • Template:Related articles start
  • Template:Related
  • Template:Related articles end

Code formatting templates

  • Template:ic
  • Template:bc
  • Template:hc
  • Template:Text art

Note templates

  • Template:Note
  • Template:Tip
  • Template:Warning

For use in drafts on discussion pages only:

  • Template:Comment

Miscellaneous templates

  • Template:App
  • Template:Broken package link
  • Template:Broken section link
  • Template:Bug
  • Template:Committed identity
  • Template:Dead link
  • Template:Lowercase title
  • Template:man
  • Template:Unsigned

Package templates

  • Template:Pkg
  • Template:Grp
  • Template:AUR

Table cell templates

Text align:

NameAlignWiki markupResult
Template:Ccenter{{C|text}}
Template:Llefttext

Cell background:

NameColorWiki markupResult
Template:Rred
Template:Oorange
Template:Yyellow
Template:Ggreentext
Template:Bblue
Template:Vviolet
Template:Greygrey{{Grey|text}}

Common text:

NameWiki markupResult
Template:Yes
Template:No{{No}}
Template:-{{-}}

Category templates

  • Template:Cat main

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.