Permanently protected template

Template:Commons category: Difference between revisions

From Vigyanwiki
m (1 revision imported from alpha:Template:Commons_category)
m (1 revision imported from alpha:Template:Commons_category)
 
(One intermediate revision by one other user not shown)
Line 13: Line 13:
  Only add tracking categories to articles and categories.
  Only add tracking categories to articles and categories.
  -->{{#if:{{{1|}}}|{{#ifeq:Category:{{replace|{{{1|}}}|_|&#32;}}|{{#invoke:WikidataIB |getCommonsLink|qid={{{qid|}}}|onlycat=True|fallback=False}}|<!--
  -->{{#if:{{{1|}}}|{{#ifeq:Category:{{replace|{{{1|}}}|_|&#32;}}|{{#invoke:WikidataIB |getCommonsLink|qid={{{qid|}}}|onlycat=True|fallback=False}}|<!--
   --><!--
   -->[[Category:Commons category link is on Wikidata]]<!--


   -->|{{#ifeq:{{replace|{{{1|}}}|_|&#32;}}|{{PAGENAME}}|<!--
   -->|{{#ifeq:{{replace|{{{1|}}}|_|&#32;}}|{{PAGENAME}}|<!--
   ... the local parameter is the same as the local pagename
   ... the local parameter is the same as the local pagename
   -->{{preview warning|Commons category does not match the Commons sitelink on Wikidata – [[Template:Commons_category#Resolving_discrepancies|please check]]}}<!--
   -->[[Category:Commons category link is defined as the pagename]]{{preview warning|Commons category does not match the Commons sitelink on Wikidata – [[Template:Commons_category#Resolving_discrepancies|please check]]}}<!--


   ... the local parameter is not the pagename
   ... the local parameter is not the pagename
   -->|{{preview warning|Commons category does not match the Commons sitelink on Wikidata – [[Template:Commons_category#Resolving_discrepancies|please check]]}}}} }}<!--
   -->|[[Category:Commons category link is locally defined]]{{preview warning|Commons category does not match the Commons sitelink on Wikidata – [[Template:Commons_category#Resolving_discrepancies|please check]]}}}} }}<!--


   We don't have a locally-defined link  
   We don't have a locally-defined link  
Line 26: Line 26:


   ... so we're using Wikidata
   ... so we're using Wikidata
   --><!--
   -->[[Category:Commons category link from Wikidata]]<!--


     <!-- ... or we're using the pagename
     <!-- ... or we're using the pagename
     -->|{{preview warning|Commons category does not match the Commons sitelink on Wikidata – [[Template:Commons_category#Resolving_discrepancies|please check]]}}
     -->|[[Category:Commons category link is the pagename]]{{preview warning|Commons category does not match the Commons sitelink on Wikidata – [[Template:Commons_category#Resolving_discrepancies|please check]]}}
   }}
   }}
   }}
   }}
Line 36: Line 36:
{{Documentation}}
{{Documentation}}
<!-- Add categories to the /doc subpage, not here! -->
<!-- Add categories to the /doc subpage, not here! -->
</noinclude>
</noinclude>[[Category: Templates Vigyan Ready]]
 
[[Category:Exclude in print]]
[[Category:Interwiki category linking templates]]
[[Category:Interwiki link templates]]
[[Category:Pages with script errors]]
[[Category:Templates that add a tracking category]]
[[Category:Templates using TemplateData]]
[[Category:Wikimedia Commons templates]]

Latest revision as of 10:07, 19 January 2023

Template documentation

{{Commons category}} links to a "Category:" name in the Wikimedia Commons repository that corresponds to the article or category. If the Commons category name is misspelled or missing, the link will still appear "blue" even though the link will fail. Check the existence of the category on Commons as well as the spelling of names carefully. User:Pi bot will try to correct, or remove, links to non-existent categories. In articles, this template should be placed at the top of the last section on the page. A warning will appear if the Commons link is not on Wikidata.

Usage

{{Commons category}} Fetches the Commons sitelink from Wikidata (where available)
{{Commons category|catname}} Puts link-box connecting title catname
{{Commons category|catname|showname}} Puts link-box showing the title showname
{{Commons category|catname|position=left}} Floats link-box to the left side, as option to align box to left-margin
{{Commons category|nowrap=yes}} Stops the text of the Commons category from wrapping
{{Commons category|lcfirst=yes}} Displays the first letter as lower-case
{{Commons category|italics=no}} Turn off italics for displayed text

The two parameters catname and showname (1 & 2) are optional, and are intended for cases where the Commons category name is different from the Wikipedia page name. The first parameter is the name of the corresponding category on the Wikimedia Commons, without the "Category:" prefix. If this first parameter is used, then the template will display the Commons category name, which may be confusing to readers. This text can be overridden by the second parameter, where the Wikipedia page name would typically be used.

For example, on the Polar bear page, {{Commons category|Ursus maritimus|Polar bears}} produces a link to Commons:Category:Ursus maritimus displayed as "Polar bears".

The parameter |position= accepts one value, |position=left, that moves the box to the left side, instead of the default right side. More information may be found at Template:Side box.

Location

If using a large, graphical template produces odd layout problems, like the excessive white space shown on the right of this screenshot, then switch to a different sister template.

Generally:

☒N Do not place this template in a section all by itself without floating left.
☒N Do not place this template in a section containing columns without floating left.
☒N Do not indent this template with colon (:) or a bullet (*) markup.

Specifically:

  • In articles, this template should be placed at the top of the last section on the page.
  • In disambiguation pages, this template is usually placed at the top of the page.
  • In categories, this template should be grouped with other templates at the beginning of the category introduction. This avoids unnecessary white space as any text is floated around the template boxes.

Resolving discrepancies

This template compares locally-defined values against the interwiki links to Commons stored on Wikidata. The discrepancies are highlighted through the addition of maintenance categories. Pages can be removed from the tracking categories by correcting the local link; removing misplaced template uses; fixing the sitelinks on Wikidata; or expanding the category system on Commons. Ideally there should be one Commons category link per article, and it should be easy for readers to identify the related content on Commons. Some suggested approaches are:

The link is to a more general topic than the article:

  1. Is there a more specific Commons category that could be linked to instead?
  2. If not, could it be created with images connected to the article?
  3. Or if there aren't any images connected to the article on Commons, could the Commons category link be removed?

There are links to multiple Commons categories in the article:

  1. Could they be replaced by a single Commons category that has the rest as subcategories?
  2. Do all of the Commons categories still exist?
  3. Are they all necessary, or could they be removed?

The Commons category links back to the wrong Wikipedia article:

  1. Can you move the sitelink to the Wikidata item for the article?

Tracking categories

Normal categories

Maintenance categories

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools.

Commons category

[[Category:Templates using TemplateData{{#translation:}}]]

This template creates a small box containing a link to a category on Commons. If no value is provided the Commons category value from Wikidata is used, and if none was provided there then the page name is used.

Template parameters

ParameterDescriptionTypeStatus
Category name1

The name of the Commons category this template will link to. If no value is provided the Commons category value from Wikidata is used, and if none was provided there then the page name is used.

Stringoptional
Displayed text2

The text that the link will display to the user. If no value is provided it will default to category name or page name, in that order.

Stringoptional
Positionposition

When set to 'left', the template will be positioned on the left side of the page. Otherwise it will default to the right side.

Stringoptional
nowrapnowrap

Stops the text of the Commons category from wrapping

Stringoptional
lcfirstlcfirst

Displays the first letter as lower-case

Stringoptional

Redirects

See also