Template talk:Commons category
Add topic| Template:Commons category is indefinitely protected from editing as it is a heavily used or highly visible template. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify a template editor to make the requested edit. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
| This template does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||
| ||||||||
- See also Wikipedia:Sister projects
|italics=no not working
[edit]For example... RodRabelo7 (talk) 04:39, 26 April 2024 (UTC)
Extra space when the template is floated to the left
[edit]Greetings and felicitations. In Mavai_Senathirajah#External_links I am seeing extra space below the template when it is floated left that is not there when it is on the right. Would someone please be so kind as to fix this? —DocWatson42 (talk) 22:50, 5 February 2025 (UTC)
- Have you tried to remove the blank line between this template and the subsequent navboxes? (And why isn't {{Commons category-inline}} a better option?) -- Michael Bednarek (talk) 02:35, 6 February 2025 (UTC)
Automating lowercasing of first letter for common nouns
[edit]Despite the |lcfirst=yes option, many instances of this template that could be lowercased have capitalized first letters. I wonder if it'd be possible to automatically detect this, perhaps by referencing Wikidata labels (which tend to be lowercase for common nouns) or something else. Sdkb talk 21:43, 23 August 2025 (UTC)
- Are there examples of what should be lowercased and what shouldn't? 174.138.218.72 (talk) 18:23, 24 August 2025 (UTC)
- The template output is formulated as a sentence so I guess Sdkb wants lowercase for everything which would normally be lowercase in a sentence, for example changing Lakes to lakes when commons:Category:Lakes is linked. The template documentation doesn't say when to use lcfirst. I thought it was only meant for lowercase Commons categories like commons:Category:eBay. Lakes is in italics and is the only linked term so it stands out, and the link goes to a page saying Lakes. My interpretation is that "Lakes" isn't merely a word in a sentence but a reference to the category and should use uppercase when the category does. PrimeHunter (talk) 19:37, 24 August 2025 (UTC)
- Ah, we should indeed resolve that usage question first. (The first step is finding whoever added that parameter without usage documentation and trouting them for it...)
- In the example that led me here, White chocolate#See also, because it's two words, it would've looked a little weird to capitalize the first but not the second. Your perspective also makes sense, PrimeHunter, although the more I think about it, the more the italics seem weird. Since the wording of the template is "related to", and the images at Commons are related to the concept the article is about. Sdkb talk 19:58, 24 August 2025 (UTC)
- Why would we ever do this? We don't use e.e. cummings case here, we use Sentence case. Even for regular nouns, not proper nouns, the first letter of a title is capitalised. Andy Dingley (talk) 20:12, 24 August 2025 (UTC)
- There would be no discussion if it very directly referred to the category name with something like "Wikimedia Commons has related media in the category Lakes." But it says "Wikimedia Commons has media related to Lakes." The category reference is more indirect but I still think, especially with the italics which wouldn't be used in a normal sentence, that it should follow the category name. Also for commons:Category:White chocolate. With lowercase, a reader might think that lakes or white chocolocate is an article link and they should click the Commons icon for the media. That's another issue: I think we should delink the icon like {{Sister project links}}. PrimeHunter (talk) 20:42, 24 August 2025 (UTC)
- Nobody thinks this. Andy Dingley (talk) 21:20, 24 August 2025 (UTC)
- The delinking icons question looks like it involves more complexity than you'd initially think; I've taken it up here. Cheers, Sdkb talk 01:42, 25 August 2025 (UTC)
- Another possibility is to extend the link to the text "media related to white chocolate". Clicking the link takes the reader to some media, not to some chocolate nor an article about chocolate. Certes (talk) 10:45, 25 August 2025 (UTC)
- That's an excellent solution to the MOS:EGG issue. Sdkb talk 17:38, 25 August 2025 (UTC)
- There would be no discussion if it very directly referred to the category name with something like "Wikimedia Commons has related media in the category Lakes." But it says "Wikimedia Commons has media related to Lakes." The category reference is more indirect but I still think, especially with the italics which wouldn't be used in a normal sentence, that it should follow the category name. Also for commons:Category:White chocolate. With lowercase, a reader might think that lakes or white chocolocate is an article link and they should click the Commons icon for the media. That's another issue: I think we should delink the icon like {{Sister project links}}. PrimeHunter (talk) 20:42, 24 August 2025 (UTC)
Convert template to Lua?
[edit]I propose that this template use the same Lua implementation (Module:Commons link) that other Commons templates (e.g., {{Commons}}, {{Commons category-inline}}, {{Commons-inline}}) have had for years. This will simplify maintenance and reduce the computational burden of rendering pages. The Lua version of the template is implemented at {{Commons category/sandbox}}.
The Lua code already uses the same tracking categories as this template. The logic to select the Commons page is almost the same: there is one minor difference in the Wikidata logic. Multiple Wikidata fields (Commons sitelink, P910, P1754, and P373) are searched for the Commons category. In the current template, the first field that contains an entry is used. In the Lua version, if there is any contradiction between the fields, the article is placed into a tracking category and Commons search is used instead. This more conservative logic has been in place for years on hundreds of thousands of pages.
Any comments or questions on the proposal? — hike395 (talk) 19:03, 4 August 2026 (UTC)
Implemented Hearing no objection, I went ahead and converted the template. Please let me know if you see anything anomalous. — hike395 (talk) 13:35, 11 August 2026 (UTC)