How do I edit templates on Wikipedia

Help: MediaWiki / Templates / Create templates

A template is a page that can be used as a text module, i. H. as ready-made text that is inserted into another text. This page covers the general use and creation of templates. The templates available for the SELFHTML-Wiki are described on the pages Category:! Templates and Help: MediaWiki / Templates.

Create and edit templates [edit]

Templates are created like any other wiki page, they always have the prefix in front of their name:.

A template is edited like a normal page. Templates can be nested; H. Further templates can be used within a template.

All templates integrated in a page are listed as links under the edit window. Templates that have just been removed will continue to be displayed there until they are saved again.

Binding information on color design can be found under Help: SELFHTML color table.

You can find an overview of existing templates under Help: SELFHTML boxes.

Use templates [edit]

Templates are framed with two curly brackets. There are four ways to use a template in an article:

  1. inserts the template into the page. The use of the prefix is ​​optional when inserting a template. When the page is displayed, the MediaWiki software then replaces this with the content of the “Title” template. If someone changes the template, the display also changes.
  2. also inserts the content of the template, but replaces the text when you save it. In this way, for example, a series of pages can always be given the same basic structure without having to copy this into each one; the editor then "only" has to add his text.
  3. embeds the content of the template each time the page is called up. If the template changes, the insertion changes. However, the code is displayed unprocessed (as with).
  4. Pages that are not in the template namespace can also be used as templates if the namespace is specified. For example, {{Help: Search}} would include the Help: Search page. If you want to include a page from the article namespace, you have to put a colon in front of the name: For example, {{: Test}} would include the article Test as a template. The best way to practice this is on your playground :-).

Everything that is between and in a template is only displayed if the template is integrated on another page. With you can add all pages that contain a certain template to a category (in the example of the category).

Everything between and in a template is only displayed when the template is viewed directly. You can use to categorize templates or add an explanation of how the template will be used.

Insert and use parameters [edit]

If content is to appear in a template that changes from page to page, for example additional text in the imaginary one, this is done with parameters.

In the template, three curly brackets indicate consecutively numbered placeholders:

According to {{{1}}}, this spinach is from the {{{2}}} company.

Using leads to the following result:

According to Popeye, this spinach is from the Oglu company.

In the template, three curly brackets indicate freely named placeholders:

According to {{{name}}} this spinach is from the company {{{company}}}

Using leads to the following result:

According to Popeye, this spinach is from the Oglu company.

The use of freely named parameters is recommended for templates that contain several parameters that can easily be confused.

A parameter can also appear to be clickable as a link if it is surrounded by two square brackets (internal wiki link) or only one pair of square brackets (external link): [[{{{1}}}]].

In the template, three curly brackets indicate consecutively numbered placeholders. The first is marked as an internal wikilink:

According to [[{{{1}}}]], this spinach is from the {{{2}}} company.

Inserting

{{Blub | Popeye | [http://spinat.example.com Oglu]}}.

results in:

According to Popeye, this spinach is from the Oglu company.

Note the difference: By using the double pair of brackets in the template, the first entry is always and inevitably an internal Wikilink. The second parameter is not inherently a link. However, by entering the parameter in link syntax, it became a (here: external) link.

In addition, there are also some predefined variables in MediaWiki that are useful as parameters, for example to insert the name of the current page ().

If a parameter is not filled with content, the code used appears, for example. This can be avoided by defining a default value:

Define standard value [edit]

A parameter can be defined in such a way that an entry is optional, without an entry a previously defined parameter is used. To do this, first enter the placeholder within the triple curly brackets, then a vertical line () and then the defined parameter value: If the parameter entered is output, otherwise the name of the article.

Problem: equal sign in parameters [edit]

If you pass a parameter to a template that is only linked by a number in the template code, text that contains an equal sign, the MediaWiki software “thinks” that you want to take the parameter with the name of the text in front of the equal sign.

This problem arises, for example, when you want to link a URL that contains an equal sign () to a parameter.

To get around this problem, you just have to prefix the parameter in which it occurs, for example the -th parameter (replacing with the corresponding number and not counting the name of the template).

Instead of:
The following:

Another example, if you add a style want to assign:

Instead of:
The following:

Problem: vertical line in parameters [edit]

Since the character “” is used to separate parameters, it cannot appear directly in parameter values. So that the vertical line can be used in parameter values, for example as table syntax, there are the following special templates that should only be used in parameter values:

parameter
content

see also [edit]

Possible uses [edit]

Templates only make sense if there are only a manageable number of them that users can remember. In particular, templates should not be created twice or very similar.

Templates are used to:

  • Consistency maximization: A uniform appearance can be achieved with templates, such as Wikipedia template definition.
  • Redundancy minimization: If the content is defined centrally in only one place (i.e. in a template), then the content will appear the same in all articles, even if it is subsequently changed. The tedious and error-prone transfer of a change to each article is no longer necessary. Examples are the so-called Wikipedia navigation modules.
  • Workflow optimization: With a template, a wiki author can tell other wiki authors precisely in which direction an article should be improved. An example is the template: ToDo. When using the templates, the article is automatically entered in special categories.
  • Code optimization: Some beautiful presentations can only be achieved with an unsightly mix of wiki markup, HTML or CSS. The article source code then quickly becomes confusing and scares away Wikian beginners from participating in the further improvement of an article. Here a template can help to make the article source code more readable.

They should not serve as:

  • User signatures
  • Abbreviations for long words (e.g. for cascading style sheets)

Document templates [edit]

Templates that are used in normal articles should be designed so simply that the purpose and application are immediately understandable. In any case, a description of their function is necessary, preferably directly on the template page, in brackets from. The opening noinclude tag should follow the code of the template directly (without a line break) in order to prevent the line break from creating unwanted spaces when using the template.

Note with noinclude [edit]

A brief explanation can be given with the command below or above a template. A brief explanation is advisable if a parameter example is sufficient.

Detailed documentation on the discussion page [edit]

The talk page of a template is more suitable for detailed documentation, especially if headings are used. The following structure is recommended:

  • Function: This template is used to suggest an article for deletion
  • Use:

To explain a number of parameters, it is useful to use the following code as a basis:

<div style="margin:1em; padding:1em; border:solid 1px #FF0040; background-color:#FFFFFF"> ==Funktion== Diese Vorlage tut dies und das. ==Parameter== ; Parameter 1: Dies. ; Parameter 2: Das. </div>

The code produces the following:

Function [edit]

This template does this and that.

Parameter [edit]

Parameter 1
This.
Parameter 2
The.

If further points about the template need to be explained, expand the scheme accordingly.

Categorization [edit]

Each template should be grouped into a category. Please note that this is done within, so that only the template is assigned to the category and not all pages in which the template is used.

Web links / sources [edit]