Background
While pages and revisions have been cleanly separated in our database schema since 2004 with a stable page_id that is used throughout MediaWiki.
File uploads, on the other hand, did not have a stable primary key in that way. I proposed fixing this in 2011 (T589) and after 25 years, are are now in the midst of those schema changes rolling out this and last quarter years (T28741). However, these new file IDs are yet to be adopted anywhere.
In any case, this is why files are generally identified by their current filename (i.e. "Example.jpg"). This is chosen during upload, and is then controlled via the File description wikipage (i.e. [[File:Example.jpg]]) which, like any wiki page, can be renamed. More about issues with that in T20493: RFC: Unify the various deletion systems.
Given that file names may be upto 250 characters in length, and the fact that they can change, we introduced the File::getDescriptionShortUrl method in 2015 for use by MediaViewer. Specifically, for use in the recommended "credit" when downloading an image to then re-use in an offline publication, or on your own website (T20493). The method uses an "ugly" /w/index.php URL with a curid parameter (pointing to the File description's page ID).
Credit example from this photo:
By Dominicus Johannes Bergsma. - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=162667099
Alternative without this feature:
By Dominicus Johannes Bergsma. - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/wiki/File:Euphorbia_griffithii_(wolfsmelk)_22-03-2025_(d.j.b.)_01.jpg
Source code: Codesearch
Problem
- This URL is statically prevented from crawling by search engines because it uses /w/index.php, and that is categorically excluded from crawling without even hitting the page in question.
This is a good thing, as we'd otherwise get a ton of expensive, uncachable traffic on our backends just to tell the crawler the URL shouldn't be indexed (e.g. endless pagination on special pages, action=history, oldid permalinks from the revision history, action=edit, and lots and lots more).
- This URL does not redirect to the canonical page.
Even if we hacked around the robots.txt classification, it's still expensive to serve, likely uncached, and doesn't redirect. MediaWiki (correctly) serves it with a noindex instruction, because it's a non-canonical URL.
<meta name="robots" content="noindex,follow,max-image-preview:standard"> … <link rel="canonical" href="https://commons.wikimedia.org/wiki/File:Euphorbia_griffithii_(wolfsmelk)_22-03-2025_(d.j.b.)_01.jpg">
- These short URLs are (likely) negatively affect page rank in search engines
Incoming links to these media files (both from our own webpages, but also from the web at large) should boost the ranking of the Commons page in question, and give it additional relevance based on the link's context via the pagerank link graph. However, this is likely short-circuited due to the short URLs being non-indexable, and thus preventing search engines like Google from crawling these.
Proposal A
- Change the Special:Redirect/page/:page_id destination to use the canonical URL for the corresponding title (instead of /w/index.php?curid=). This currently suffers from the same issue described above, wasting crawler resources on a redirect only to end up un-crawlable and affecting SEO for the same reason. I would additionally suggest introducing Special:Page as alias for this, the same way that we have Special:Permalink for Special:Redirect/revision, and Special:Diff.
- Swap the implementation from /w/index.php?curid= to /wiki/Special:Page
By Dominicus Johannes Bergsma. - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/wiki/File:Euphorbia_griffithii_(wolfsmelk)_22-03-2025_(d.j.b.)_01.jpg
Proposal A+B
We can optionally go a step further in WMF production and additionally let the WikibaseMediaInfo extension make these URLs even nicer: https://commons.wikimedia.org/entity/M162667099
This is from the "Concept URI" in the sidebar. (Yes, that is indeed the same page ID. See also WBMI/MediaInfoHandler and WBMI/Hooks.)
See also: