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.
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:
Also, the introductionary explanations of the sister project Wikipedia are of great help for beginners:
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.
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 {{es-conj}}
automatically generates a table with a full set of inflected forms of a Spanish verb, while {{en-noun}}
is capable of automatically showing the plural form of many English nouns.
While it may be easier to use generic templates like {{head}}
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.
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, {{en-verb}}
is intended to be used for English entries, {{nl-adj form of}}
for Dutch entries, {{fr-conj-auto}}
for French entries, {{sl-decl-adj}}
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, templates with specific types have names beginning with a prefix, followed in most cases by a language code and then another colon, and then a short, descriptive name. A small number of templates may be applicable across multiple languages and may omit the language code. These types are shown at the table below.
Type | Name prefix (without language code) |
Example | Notes |
---|---|---|---|
General | - | {{en-noun}} |
Just use the language code then a dash "-". |
Usage note templates | U: |
{{U:en:less and fewer}}
| |
Reference templates | R: |
{{R:mia:Costa:2003}} {{R:Etymonline}}
| |
Reference & quotation templates | RQ: |
{{RQ:Atlantic}}
| |
List templates | list: |
{{list:provinces of the Philippines/en}} |
Language codes are after the description, after a "/" |
Auto-table templates | table: |
{{table:Brazil/en}}
|
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 Wiktionary:Grease pit to gain consensus before requesting that the changes be made by a template editor.
To display a link to a template page presented in the style of a call to that template, you can use:
For example:
produces:
{{quote}}
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 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, {{head}}
should be used.
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, {{nl-verb}}
is for the headword line of Dutch verbs, {{en-noun}}
is for English nouns, and so on. The following abbreviated part-of-speech names are currently in common use:
adj
adv
con
det
interj
noun
num
part
postp
prep
pron
proper noun
verb
Languages may extend these names if they need templates for more specific purposes, such as {{nl-noun-dim}}
for Dutch diminutive nouns. It's common to add -form
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 {{nl-adj-form}}
for Dutch adjective forms.
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 {{PAGENAME}}
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.
{{head}}
from within the template. This allows the template to use the additional features that {{head}}
provides, such as automatic script detection, transliteration and link processing. Examples:
{{head|fr|noun|head={{{head|}}}}} {{head|ru|noun|head={{{head|}}}}}
|class="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:
<strong class="headword" lang="fr">{{{head|{{PAGENAME}}}}}</strong>
<strong class="headword Cyrl" lang="ru">{{{head|{{PAGENAME}}}}}</strong>
'''{{{head|{{PAGENAME}}}}}'''
For languages that have grammatical genders, the gender usually immediately follows the headword. Genders should be formatted using Module:gender and number or through {{g}}
. 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 {{head}}
). 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 {{ca-noun|m}}
is preferred to one that is used like {{ca-noun|g=m}}
(the ca-noun
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 {{fr-noun|n}}
, 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.
Following the headword and optional gender information, you can choose to display additional forms of the word, surrounded by parentheses. {{en-verb}}
displays the various forms of an English verb, for example, while {{nl-adj}}
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 {{l}}
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'' <b lang="nl">]</b>, ''diminutive'' <b lang="nl">]</b>) (''genitive'' <span lang="sl">''']'''</span>) (''simplified'' <b lang="cmn" class="Hani">]</b>, ''pinyin'' <b lang="cmn-pinyin">mǎ</b>, ''Wide-Giles'' <b lang="cmn-wadegile">ma<sup>3</sup></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. {{nl-noun}}
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. {{en-verb}}
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").
It is generally expected that every headword-line template will add the entry to a category corresponding to its part of speech. {{en-verb}}
adds the entry it is added to Category:English verbs, {{fr-noun}}
adds it to Category:French nouns, {{nl-adj-form}}
adds it to Category:Dutch adjective forms. The template {{head}}
has a parameter to specify the language and category: {{head|ru|adjective}}
adds the entry to Category:Russian adjectives.
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:
<div class="NavFrame">
<div class="NavHead">(text to display when the table is collapsed)</div>
<div class="NavContent">
(put the table itself here)
</div>
</div>
By convention, tables that show the forms of nouns, pronouns and adjectives are named decl
and are placed in a ====Declension====
section on the page, while tables that show the forms of verbs are named conj
and are placed in a ====Conjugation====
section. Usually, the name also includes the specific inflection type or class that the word may follow, or its abbreviation. {{la-ndecl}}
is used for Latin nouns, for example, and {{nl-decl-adj}}
for Dutch adjectives, while {{es-conj}}
is used for Spanish verbs.
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 locate and its past-tense form located. 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. {{comparative of}}
, when provided with the parameter |lang=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: {{comparative of}}
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.
(please expand)
{{label|____}}
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 (mathematics) appear, one may use {{label|en|mathematics}}
and the term will also be added to Category:en:Mathematics.{{qualifier|____}}
Shows the given qualifiers in a reader-customizable style, e.g., (qualifier). 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.(please expand)
Templates for entering quotations (also Category:Citation templates):
{{quote-book}}
{{quote-journal}}
Templates for referring to sources in quotations:
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: {{trans-top|inevitable passing of events}}.
{{trans-top}}
{{trans-bottom}}
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: {{rel-top|terms derived from ''time''}}. 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.
{{rel-top}}
{{rel-bottom}}
Very long lists can be formatted in four columns using the following:
{{rel-top4}}
{{rel-bottom}}
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 {{trans-top}}
etc. as described above.
Etymology templates:
{{derived}}
(shortcut {{der}}
){{borrowed}}
(shortcut {{bor}}
){{learned borrowing}}
(shortcut {{lbor}}
){{orthographic borrowing}}
(shortcut {{obor}}
){{inherited}}
(shortcut {{inh}}
){{PIE root}}
{{blend}}
{{clipping}}
{{short for}}
{{back-form}}
(shortcut {{bf}}
) (longcut {{backformation}}
){{doublet}}
(shortcut {{dbt}}
){{onomatopoeic}}
(shortcut {{onom}}
){{calque}}
(shortcut {{cal}}
), (shortcut {{clq}}
){{semantic loan}}
(shortcut {{sl}}
){{named-after}}
{{phono-semantic matching}}
(shortcut {{psm}}
){{mention}}
(shortcut {{m}}
){{cognate}}
(shortcut {{cog}}
){{noncognate}}
(shortcut {{noncog}}
){{langname-mention}}
(shortcut {{m+}}
) – like mention but also can generate a Wikipedia link for the language when used with w=1
{{rfe}}
{{etystub}}
{{unknown}}
(shortcut {{unk}}
) – only for words where no etymological information exists{{uncertain}}
(shortcut {{unc}}
)Languages: These templates "wrap" the language abbreviations used in Webster 1913 (see Wiktionary:Abbreviations in Webster#Languages). 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 Wiktionary:Categorization).
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.
External links:
{{wikipedia}}
— Inclusion of this inserts a highly visible link to Wikipedia for the same word/topic. If there are enough headings, then this should go above the ==English== header line to make it appear correctly.{{slim-wikipedia}}
– Suitable for Wikipedia links on smaller pages{{wikisource}}
{{wikibooks}}
{{w}}
{{pedialite}}
— A simple one-liner entry that gets tucked away in ===Further reading===
to link to Wikipedia with the page title.See also Category:Pronunciation templates and Wiktionary:Pronunciation#Section layout and templates.
The main pronunciation templates are
Reference templates, templates used to link to external sources used as a reference:
Reference templates have names beginning with R:, see #Naming_templates, above.
Some often used reference templates:
{{R:Webster 1913}}
{{R:Century 1911}}
{{R:OneLook}}
{{R:L&S}}
- Charlton T. Lewis & Charles Short, A Latin Dictionary, Oxford: Clarendon Press, 1879Request templates (also Category:Request templates):
Request templates for dictionary entries in the main namespace. Parameters are optional, unless marked with an asterisk (*). (See Wiktionary:Maintenance templates for additional information.)
Deletion and verification:
{{delete|reason}}
- Request for immediate deletion of mistakes, vandalism, and other garbage{{rfd|langcode|reason}}
- Listed request for deletion of potentially encyclopedic or non-idiomatic terms{{rfd-redundant|langcode|fragment=link text}}
- Request for deletion of sense; the definition is redundant{{rfv|langcode|reason}}
- Listed request for verification; entry is disputed at WT:RFV{{rfv-sense|langcode|fragment=link text}}
- Request for verification of sense; the sense is disputed at WT:RFVLanguage and translations:
{{t-needed|langcode}}
- Request for translations; this English article needs translation into other languages{{rfscript|langcode|sc=script name}}
- Request for foreign-language scriptInformation and cleanup:
{{rfap|langcode|reason}}
- Request for audio pronunciation; an audio file is wanted{{rfc|langcode|reason}}
- Request for cleanup; the article is not formatted well{{rfdate|langcode}}
- Request for date; the quotation lacks a date{{rfdef|langcode|reason}}
- Request for definition; the entry lacks a definition{{rfe|langcode|reason}}
- Request for etymology; the entry lacks an etymology{{rfp|langcode|reason}}
- Request for pronunciation; the entry lacks a pronunciation (e.g. IPA){{rfi|langcode|reason}}
- Request for image (drawing, photo, as available){{tea room|langcode|reason|y=year|m=spelled out month|fragment=link text}}
- Entry is under discussion in the Tea RoomOther entries:
Request templates for pages in other namespaces:
{{delete|reason}}
- Request for immediate deletion of mistakes or vandalism{{rfd|langcode|reason}}
- Request for deprecation of categories and templates or deletion of other pagesResults of requests:
See Wiktionary:Script templates and Category:Script templates.
Templates for Appendix:Swadesh lists.
{{Swadesh list 207 plain}}
: plain list (English and selected language){{Swadesh list 207 pronunciation}}
: list with IPA pronunciation{{Swadesh list 207 trans pronunciation}}
: list with transcription and pronunciation{{Swadesh list 207 trans}}
: list with transcription in Latin characters{{Swadesh list 207 trans2}}
: list with two transcriptions{{Swadesh lists}}
: box with all Swadesh lists of individual languages, language families and branches{{Swadesh list presentation}}
: Swadesh list presentation template{{Swadesh list templates}}
: displays all templatesTemplates used in WT:Thesaurus:
{{ws header|Xxx}}
- 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.{{ws beginlist}}
- Top of list of Thesaurus line entries{{ws|Xxx|Yyy}}
- Single line Thesaurus entry - Xxx is the entry word, Yyy is a brief definition/usage note.{{ws endlist}}
- Top of list of Thesaurus line entriesSee also Wiktionary:Thesaurus#Templates.
See Category:User warning templates.
{{African lists}}
: box with vocabulary lists of African languages, proto-languages, language families and branches{{MSEA lists}}
: box with vocabulary lists of Mainland Southeast Asian languages, proto-languages, language families and branchesWelcome templates (also Category:Welcome templates):
{{welcome}}
{{welcomeip}}
{{pediawelcome}}