Wiktionary:Templates

A template is a page in the Template: namespace, which contains special wiki code that allows it to be reproduced ("transcluded") on many different pages. Templates can either be transcluded directly, or you can pass on additional information (through "parameters") to the template that controls or modifies its behaviour.

The advantage of using templates is that when the template itself is changed, all pages that transclude the template will automatically be updated as well. This helps in reducing the duplication of identical content, and templates are a powerful tool for keeping the appearance of certain parts of a dictionary entry consistent. For example, a single template to generate a table of inflected forms of a verb can be used on hundreds of different pages, but will look and function the same on each one. Generally speaking, if you find yourself having to add more or less the same thing on several pages, it's probably better to write a template instead and transclude it onto the pages.

Wiktionary makes heavy use of templates, so it is a good idea to familiarise yourself with how they work and how to use them, even if you don't write your own. Templates can be found in Category:Templates and its subcategories.

Writing templates
Templates may either use a Scribunto module as underlying mechanism, or be written directly in template code. Although Scribunto is strongly preferred for templates with complex logic, a straightforward string-assembly template probably doesn't need a module. Some templates may also mix both, calling on Scribunto for some parts while using template/wiki code for the remainder.

Here are some good guides for using and writing templates:
 * Meta:Help:Template
 * Meta:Help:A quick guide to templates
 * Meta:Help:Advanced templates
 * MediaWikiWiki:Help:Extension:ParserFunctions – template functions such as #if and #switch
 * Meta:Help:Editing sections of included templates
 * Meta:Help:Parameter default
 * Meta:Help:Variable
 * Meta:Help:Array

Also, the introductionary explanations of the sister project Wikipedia are of great help for beginners:


 * Wikipedia:Help:Template
 * Wikipedia:Help:Template

If you want to create a new template, but you're still inexperienced with them or with Wiktionary in general, it's probably best to ask first (at the WT:Grease Pit). Maybe there isn't really a need for such a template, because the problem you are trying to solve with it can be approached differently. Maybe someone else already wrote something similar to your idea; it would be better to use what already exists instead of doing it all over again. For that reason, the best way to "learn" templates is probably to study the ones we already have on Wiktionary.

Language-specific templates
Many languages have their own set of templates, which can be found in one of the subcategories of Category:Templates by language. Language-specific templates are better able to cater to the needs of a specific language than a general template can, and allow for specific exceptions or restrictions that general templates don't. Because they are made for a specific language, knowledge of that language's grammar can be embedded into them. For example, the template automatically generates a table with a full set of inflected forms of a Spanish verb, while  is capable of automatically showing the plural form of many English nouns.

While it may be easier to use generic templates like to start off with, you'll eventually come to a point where it's better to create a tailor-made set of templates for your language. At that point, however, you'll already have all the "old" entries to deal with, which still use the generic all-language templates, which you'll then have to fix. For that reason, it's encouraged to create at least a basic set of headword-line templates (see below) for each language, before you start to create entries in that language.

Naming templates
Try to use a name that is both short and descriptive. As a rule of thumb, the more often the template will be used, the more leeway there is in using a short name. Templates that are used only within other templates should have longer names, as they generally don't need to be used that often. If you can, try to avoid using characters outside the ASCII encoding (use only the Latin alphabet), so that everyone can easily type the template's name.

Templates that are intended specifically for one language should have a name that begins with that language's language code, followed by a hyphen. For example, is intended to be used for English entries,  for Dutch entries,  for French entries,  for Slovene, and so on. What follows after the code is up to the creator of the template, but there are certain naming conventions that are followed, on which more below. If you are writing a template for a specific language, you include any of the characters that are used in that language as part of the name. However, even then, using just the Latin alphabet is preferable.

By convention, usage-note templates have names beginning with U:, followed in most cases by a language code and then another colon, and then a short, descriptive name; for example, Template:U:en:less and fewer. (A small number of usage-note templates may be applicable across multiple languages and may omit the language code.) Reference templates have names beginning with R: (optionally followed by a language code and then another colon) and then a short, descriptive name; for example, Template:R:mia:Costa:2003 or Template:R:Etymonline.

Changing existing templates
Special care should be taken when making changes to an existing template, since the changes will (potentially) affect all pages that transclude the template. Depending on the editing interface you are using, you should be able to preview your changes before publishing them (in the standard editor the relevant features are called "Show preview" and "Show changes"). You may also be able to preview (before publishing) how another page that calls the template you are editing will look once your changes are applied ("Preview page with this template").

Most of our templates can be modified by any user, but sometimes templates are protected from editing by regular users. In such a case, proposed changes can be discussed on the template's associated discussion page or in Grease pit to gain consensus before requesting that the changes be made by a template editor.

Showing a link to the template page and documentation
To display a link to a template page presented in the style of a call to that template, you can use:

For example:

produces:

where you can follow the link to see how to use the "quote" template. This is useful in discussions and in template documentation, but should not be used in our dictionary entries.

Headword-line templates
Headword-line templates are templates that are used to produce the headword line of a term. (historical note: this was formerly called the "inflection line", and headword-line templates used to be called "inflection templates") The headword line is the line that comes immediately below the header specifying the part of speech (such as Noun or Verb). At the very least, the headword line contains the headword in question, specially formatted in bold text. Additional information may also be presented on the headword line, such as the gender of a noun (for languages where that applies), or a selection of inflected forms.

Most languages have their own set of headword-line templates; these are the most common form of language-specific template. In cases where the language lacks an appropriate headword-line template, should be used.

Naming
Headword-line templates are named using the language code, followed by an abbreviated form of the part of speech that the template is used for. For example, is for the headword line of Dutch verbs,  is for English nouns, and so on. The following abbreviated part-of-speech names are currently in common use:
 * Adjective:
 * Adverb:
 * Conjunction:
 * Determiner:
 * Interjection:
 * Noun:
 * Numeral:
 * Particle:
 * Postposition:
 * Preposition:
 * Pronoun:
 * Proper noun:
 * Verb:

Languages may extend these names if they need templates for more specific purposes, such as for Dutch diminutive nouns. It's common to add  at the end if the template is to be used for words that are not full dictionary entries (they are not lemmas) but are a form of another word. For example for Dutch adjective forms.

Formatting the headword
The headword itself appears in boldface, unless it's in a writing system where bold text is harder to read, in which case it appears with a larger font-size (this is controlled through MediaWiki:Common.css). Within the template's code, the  magic word is used to automatically display the name of the current page. Most headword-line templates also provide a parameter named head, which allows other editors override this default display, in case this is desired (for example, if additional accent marks should be displayed on the headword). Some templates may use other names for this parameter, but head is the most common and the most standard, so it is preferred for the sake of easy interoperability.

There are a few different ways that headword lines have been created in the past using a template. Not all of them should be used anymore, but you may encounter such code in older templates and entries that have not been brought up to date.   The currently preferred method is to invoke from within the template. This allows the template to use the additional features that provides, such as automatic script detection, transliteration and link processing. Examples:  An older method was to write the raw HTML: the "strong" HTML element with the "headword" HTML attribute. This element is provided with a lang HTML attribute to specify the language code of the language that the word is part of. An additional HTML class, the script code, should be provided if the headword is not written in the Latin alphabet but in some other writing system like Cyrillic or Chinese. Examples:   A still older method was to simply surround the headword with wikicode to make it appear bold. This method is deprecated and discouraged because it does not supply the appropriate language or styling information, which is needed by browsers to select the correct fonts and provide further support for the language (such as adjusting the language of a screen reader).   

Genders and other grammar information
For languages that have grammatical genders, the gender usually immediately follows the headword. Genders should be formatted using Module:gender and number or through. Many templates allow you to indicate the gender by passing it as the first numbered parameter, although the g parameter is also commonly used (it is used by ). Writing the template to use the numbered parameter is preferred, however, because it's less likely to be overlooked by other editors – you have to consciously "skip" the first parameter to get to the second, which makes it more obvious when you forget it. Thus, a template that is used like is preferred to one that is used like  (the   template itself already uses the first format, so using the second is an error in this case).

It's usually good coding practice to add code to the template that checks whether the gender that has been provided to the template is valid. For example, French has no neuter gender, so if someone writes, then that is an error. If it's not valid, the template should add the page to a cleanup category such as Category:French nouns lacking gender, so that it can be corrected.

Inflected and related forms
Following the headword and optional gender information, you can choose to display additional forms of the word, surrounded by parentheses. displays the various forms of an English verb, for example, while displays the comparative and superlative form of a Dutch adjective.

When displaying and/or linking to forms in the template, you can either use a generic linking template like or, preferably, write out the link manually. When writing out the link, always link to the appropriate section. You should also provide the language code (with the lang HTML attribute) and a HTML class for the script code if it's not Latin. The forms should be displayed in bold while the grammatical information (such as "comparative" or "past tense") is displayed in italics. This should be done even if the letters don't normally look right in bold font – the language and script tags will ensure (through style sheets) that the text will not actually be bolded if it's not appropriate. Here are some varieties you can use (with example words already filled in; normally the template would determine these through other means such as parameters or the page name):

(plural woorden, diminutive woordje) (genitive bésede ) (simplified 马, pinyin mǎ</b>, Wide-Giles <b lang="cmn-wadegile">ma3</b>)

A template may need additional parameters to correctly display the additional forms, while some forms can be determined automatically. Different templates currently use different approaches. requires you to manually enter the forms, and will display a notice on the page and add the entry to a category if they are missing. on the other hand generates them automatically. There are pros and cons to both approaches. Determining the forms automatically makes things easier for the editor, because they do not have to concern themselves with the details. On the other hand, automatically-generated forms may not be correct, while they will more likely be correct if they have to be entered manually. Requiring editors to manually enter the forms also means that a user can add the template to an entry without having to worry whether the forms it has generated are correct (this is useful because an editor may not know the language but still want to add the template to an entry in that language). You will therefore have to make a trade-off. If the forms that the template can automatically generate are correct in the majority of cases, then it makes sense to do so. However, if automatically generated forms can only be correct in a small amount of cases, it makes more sense to require the editor to enter them.

Be very mindful of which forms you choose to include in this way. While a lightly-inflected language like English only has a few forms, languages like Latin may have dozens, and they could never fit onto a single line (also keep in mind that some users might have smaller screens!). If a word in your language has too many distinct forms to fit on one line (4–5 is probably about the limit) then it's better to show either no forms on the headword-line, or show only a few key forms that help users figure out the remainder themselves. For Latin verbs in particular, the four verb forms that are displayed on the headword line are the least predictable forms, which most other forms can be regularly derived from (so-called "principal parts").

Categories
It is generally expected that every headword-line template will add the entry to a category corresponding to its part of speech. adds the entry it is added to Category:English verbs, adds it to Category:French nouns,  adds it to Category:Dutch adjective forms. The template has a parameter to specify the language and category:  adds the entry to Category:Russian adjectives.

Inflection-table templates
Languages that use several different forms of the same word often use inflection-table templates. These are templates that display a table or list containing all or most of the inflected forms of a particular word. Unless they are very small, these tables should be made collapsible, by enclosing them in the following code:

By convention, tables that show the forms of nouns, pronouns and adjectives are named  and are placed in a   section on the page, while tables that show the forms of verbs are named   and are placed in a   section. Usually, the name also includes the specific inflection type or class that the word may follow, or its abbreviation. is used for Latin nouns, for example, and for Dutch adjectives, while  is used for Spanish verbs.

Form-of templates
On Wiktionary, a form-of entry is an entry for a word that is considered an inflected form of another word. Such entries don't contain a full definition. Usually the definition is a short description of the grammatical properties of this form, and a link to the main entry. Compare, for example, the entries for and its past-tense form. The definitions of such entries are generated automatically with templates. There is a wide variety of form-of templates, and many of them not specific to one language but can be used for most languages. For that reason, it is often not necessary to create form-of templates for your language. It doesn't hurt to do so anyway, but it may be considered wasteful and redundant if your template does what a generic template already does perfectly.

Some form-of templates also add the entry to a category. , when provided with the parameter da, adds the entry to Category:Danish comparative adjectives. This may or may not be desirable. Generally, the headword-line should add the category, so it is at the very least redundant if the form-of template also does this. Furthermore, a template may be used for more than one part of speech (case in point: can be used for adjectives, adverbs or determiners), and it may also conflict with the way a language's categories are structured. Therefore, it's probably good practice to not add categories with form-of templates, or to add only additional categories and not the main part-of speech category.

Context label templates
(please expand)
 *  Tag a term in a definition and add a category link for it. Put this just after the "#" character and before the definition text. For example, to have appear, one may use  and the term will also be added to Category:en:Mathematics.
 *  Shows the given qualifiers in a reader-customizable style, e.g., . The default style is with parentheses and italics. This template is intended generally only used in the definition of other templates, but may also be used directly in articles at the beginning of a list item if no other template applies.

Examples

 * — show usage examples under a definition line
 * — inline form of the

Category boilerplate templates
(please expand)

Columns
Long lists of terms (such as derived terms or translations) usually look better when formatted into columns. The templates below provide an easy method of doing this.

Current Wiktionary style is to put such material in collapsible tables so that the user can display it only if they wish to. This makes an entry easier to read and navigate. Alternatively, content may be made permanently visible. It is preferable to use collapsible tables for long lists and to make only short lists permanently visible, or to use collapsible tables for all lists (given that short lists may eventually become much longer).

To use any of these templates, place the "top" template immediately before the content and the "bottom" template immediately after.

Use the templates from one group only at any one time. Do not combine templates from different groups, as this will give odd results or might not be parsed correctly by the browser.

For "Translations" sections

The following templates display translations in two columns in a collapsible table for the translations sections. They are for use only in the Translations section of an article; in other sections, use the templates below.

The "trans-top" template takes an argument that is used as the header for the table. A gloss summarising the meaning being translated is put here. For example, in the entry for time, the gloss "inevitable passing of events" is given in the first table of translations, and this is generated thus:.



Currently, templates for collapsible translation tables are available only in two-column format.

For other lists

Collapsible tables

The following templates display lists in two columns in a collapsible table. They are for use in sections other than the Translations section of an article (not just the Related terms section, despite the name); in the Translations sections, use the templates above.

The "rel-top" template takes an argument that is used as the header for the table. A gloss summarising the content of the table. For example, in the entry for time, the table of derived terms has the header "terms derived from time", and this is generated thus:. Note that this is the preferred format of a gloss for derived and related terms (which would have the header "terms related to time"). Note that the word or phrase which the terms are derived from or related to is italicised.



Very long lists can be formatted in four columns using the following:



For lists that are always displayed

Alternatively, a list of terms can be formatted so that it is always displayed (that is, not hidden in a collapsible table). This format is best reserved for short lists.

The following templates display content in two, three or four columns. They are not for use in a Translations section of an article; in the Translations section, use etc. as described above.


 * Two columns


 * Three columns


 * Four columns

Etymology
Etymology templates:


 * (shortcut )
 * (shortcut )
 * (shortcut )
 * (shortcut )
 * (shortcut )


 * (shortcut )
 * (shortcut )
 * (shortcut )
 * (shortcut )
 * (shortcut )


 * (shortcut ) (longcut )
 * (shortcut )
 * (shortcut )
 * (shortcut ), (shortcut )
 * (shortcut )
 * (shortcut )
 * (shortcut ), (shortcut )
 * (shortcut )
 * (shortcut )
 * (shortcut )


 * (shortcut )
 * (shortcut )
 * (shortcut )
 * (shortcut ) – like mention but also can generate a Wikipedia link for the language when used with

Languages: These templates "wrap" the language abbreviations used in Webster 1913 (see Abbreviations in Webster). One function of these templates is to make transcribing etymologies from Webster 1913 simple. Another function is to expand the obscure abbreviation into the full name of the language. A third function of these templates is to automatically categorize words according to their etymologies (see Categorization).
 * (shortcut ) – only for words where no etymological information exists
 * (shortcut )
 * (shortcut ) – only for words where no etymological information exists
 * (shortcut )

These templates will automatically both add a word to an etymology category and create an interwiki link to the language article on Wikipedia, as well as expand to the name of the language, and are suitable for use in the "Etymology" section of an article.

Maintenance

 * See the separate page Maintenance templates.

Pronunciation
See also Category:Pronunciation templates and Pronunciation.

The main pronunciation templates are
 * - request for audio pronunciation
 * - request for pronunciation
 * - request for audio pronunciation
 * - request for pronunciation

Requests
Request templates (also Category:Request templates):

Request templates for dictionary entries in the main namespace. Parameters are optional, unless marked with an asterisk (*). (See Maintenance templates for additional information.)

Deletion and verification:
 * - Request for immediate deletion of mistakes, vandalism, and other garbage
 * - Listed request for deletion of potentially encyclopedic or non-idiomatic terms
 * - Request for deletion of sense; the definition is redundant
 * - Listed request for verification; entry is disputed at WT:RFV
 * - Request for verification of sense; the sense is disputed at WT:RFV

Language and translations:
 * - Request for translations; this English article needs translation into other languages
 * - Request for foreign-language script

Information and cleanup:


 * - Request for audio pronunciation; an audio file is wanted
 * - Request for cleanup; the article is not formatted well
 * - Request for date; the quotation lacks a date
 * - Request for definition; the entry lacks a definition
 * - Request for etymology; the entry lacks an etymology
 * - Request for pronunciation; the entry lacks a pronunciation (e.g. IPA)
 * - Request for image (drawing, photo, as available)
 * - Entry is under discussion in the Tea Room

Other entries:

Request templates for pages in other namespaces:


 * - Request for immediate deletion of mistakes or vandalism
 * - Request for deprecation of categories and templates or deletion of other pages

Results of requests:

Script
See Script templates and Category:Script templates.

Swadesh lists
Templates for Appendix:Swadesh lists.


 * Templates for Swadesh lists
 * : plain list (English and selected language)
 * : list with IPA pronunciation
 * : list with transcription and pronunciation
 * : list with transcription in Latin characters
 * : list with two transcriptions
 * Swadesh template categorized


 * Templates for boxes
 * : box with all Swadesh lists of individual languages, language families and branches


 * Other templates
 * : Swadesh list presentation template
 * : displays all templates

Table of contents
See Category:TOC templates.

Thesaurus
Templates used in WT:Thesaurus:


 * - Marks page as a Thesaurus entry, and list alphabetically under the Xxx entry within the Thesaurus category. Also put in top of page layout for a Thesaurus entry.
 * - Top of list of Thesaurus line entries
 * - Single line Thesaurus entry - Xxx is the entry word, Yyy is a brief definition/usage note.
 * - Top of list of Thesaurus line entries

See also Thesaurus.

User warning
See Category:User warning templates.

Vocabulary lists

 * Templates for boxes
 * : box with vocabulary lists of African languages, proto-languages, language families and branches
 * : box with vocabulary lists of Mainland Southeast Asian languages, proto-languages, language families and branches

Welcome
Welcome templates (also Category:Welcome templates):

de:Wiktionary:Textbausteine es:Wikcionario:Plantillas fr:Wiktionnaire:Liste de tous les modèles nl:WikiWoordenboek:Lijst van sjablonen pl:Wikisłownik:Szablony ru:Викисловарь:Шаблоны simple:Wiktionary:Template messages