Help:Duplicate parameters

From WikiProjectMed
Jump to navigation Jump to search

Previewing a page may produce an error message like this at the top:

Warning: Example (edit) is calling Template:Cite web with more than one value for the "date" parameter. Only the last value provided will be used. (Help)

The error happens when a page is calling a template and tries to assign a value to the same parameter (also called argument) more than once, as with two values for the date parameter in this example:

{{Cite web|date=2014|title=Cars|date=2016}}

Removing one of the date assignments will eliminate the warning, but please consider whether the real error is that one of the parameters should have been named differently, for example as "access-date=" (instead of "date=").

The message is not shown on the saved page, so readers will not see it, but it should still be fixed. Later editors may not notice the issue and mistakenly change the value of the first assignment, unaware the 2nd value will be used.

The problem also happens if the same exact value is assigned twice, as in example:

{{Cite web|date=2016|title=Cars|date=2016}}

Such cases should also be fixed to prevent future confusion. (A bot can usually fix the problem when parameter values are identical.)

A blank assignment will also cause the error:

{{Cite web|date=2014|title=Cars|date=}}

Editors often copy example code with many blank assignments, so watch out for this.

Templates can have unnamed parameters which are automatically called 1=, 2=, 3=, etc. by the software. Text with no equals sign after a pipe is interpreted as an unnamed parameter, for example |2014|. The first unnamed parameter is called "1" and so on, so this example would produce the error for "1=" as set twice:

{{Cite web|1=2014|title=Cars|2014}}

Pages with the error are automatically placed in a hidden category called Category:Pages using duplicate arguments in template calls. Its name is determined by MediaWiki:Duplicate-args-category. It is listed at Special:TrackingCategories with the description in MediaWiki:Duplicate-args-category-desc.

The error message is generated by MediaWiki:Duplicate-args-warning. The English Wikipedia has customized the English (en) version of the message to add a "Help" link to this page.

Locating the error

  • If you are moderately technical, you can install a script that lists the duplicate arguments on a page: User:Frietjes/findargdups. Only registered users can use scripts.
  • The Find feature in most browsers, usually Ctrl+F (Windows/Linux) or ⌘ Cmd+F (Mac OS), can be used on the template name or parameter name in the error message.
  • You can preview a section of the page to see whether the error is in the previewed section. For testing you can also delete parts of the page while previewing. Do not save such tests.
  • WPCleaner detects the duplicate arguments on analyzed pages, and is able to automatically fix some of them.
  • If you cannot locate the error, it may be in a transcluded page or template. The bottom of the preview window shows a list of transcluded pages under the heading "Templates used in this preview (help):".