Page MenuHomePhabricator

Re-examine the section headings at Commons
Open, Needs TriagePublicFeature

Description

User-stories

  • As a user, I want to understand the structure of a File-page at a glance.
  • As a user, I want to be able to easily navigate to a section within a File-page. – E.g. the section "File usage on other wikis".
  • As a user, I want to be able to easily send a #section link to someone. – E.g. the same as above.

Context/Problem

At Commons, there are 2 automated systems for showing a "Table of Contents" (ToC), with some of the Headings on File pages. Both of them are missing some Headings:

The Vector-2022 ToC:

  1. Doesn't include any of the filetoc headings
  2. Doesn't include the Structured Data headings

The automatic "filetoc"

  1. Doesn't include any manually-written ==Headings==
  2. Doesn't include the new Structured Data headings/tabs
  3. Doesn't work with gadgets (if the gadgets/scripts identify headings based on the standard CSS-class).
  4. Are not visible in the automated "filetoc" bar unless we click the red "x" to "Remove" (hide) the reuse-links. E.g.
    image.png (613×130 px, 10 KB)

Examples

We cannot directly navigate to the "File history" section from any of these links:

Full list of headers to consider

(Using their English-labels)

  1. filetoc:
    • File
    • File history
    • File usage on Commons
    • File usage on other wikis
  2. Structured Data:
    • File information
    • Structured data
  3. Any manually created headers

image.png (1,140×889 px, 153 KB)

Screenshot

Screenshot showing

  • (a) the "File history" header is missing from the Vector-2022 ToC, and
  • (b) that header is lacking the class="mw-headline" (which all manually-created ==Headers== have)

Commons section headers not in ToC.jpg (623×622 px, 56 KB)

See also

Proposed solution

? (research?)

Event Timeline

Are not visible in the automated "filetoc" bar unless we click the red "x" to "Remove" (hide) the reuse-links.

That may not hold true anymore, per T425153.

Change #1306091 had a related patch set uploaded (by Simon04; author: Simon04):

[mediawiki/core@master] ImagePage: Integrate the file TOC into the page table of contents

https://gerrit.wikimedia.org/r/1306091

Change #1306092 had a related patch set uploaded (by Simon04; author: Simon04):

[mediawiki/core@master] ImagePage: Include foreign-repo description headings in the file TOC

https://gerrit.wikimedia.org/r/1306092

@simon04 Just to check (I assume "yes"!), will these patches also work for
(A) Users (or wikis) with non-English language settings -- IIUC, this is already handled automagically.
(B) All other skins? -- I.e. Minerva, Monobook, Timeless, Vector (legacy); but also generic 3rd-party skins?
It might be good to add screenshots for those examples, to prove that the changes are suitable & tested for all easily-predictable situations.
P.s. Thank you immensely for working on this bug!

Yes, all skins should be supported (thanks to @Samwilson's review on gerrit).

Yes, all languages should be supported.

Here are some more screenshots:

Screenshot 2026-06-30 at 20-20-02 File Trins-260617-1640-hu.jpg – Simon04.png (851×454 px, 272 KB)

Screenshot 2026-06-30 at 20-19-20 File Trins-260617-1640-hu.jpg - Simon04.png (1,083×592 px, 102 KB)

Screenshot 2026-06-30 at 20-18-45 File Trins-260617-1640-hu.jpg - Simon04.png (894×525 px, 113 KB)

Screenshot 2026-06-30 at 20-17-30 File Trins-260617-1640-hu.jpg - Simon04.png (850×462 px, 139 KB)

The existing MinervaNeue file ToC looks like this:

image.png (513×135 px, 7 KB)

But with this patch it'll disappear completely on screens less than 640px:

image.png (547×104 px, 5 KB)

And show a collapsed ToC on wider screens:

image.png (731×173 px, 8 KB)

Is that all good? I guess mobile users are used to not having ToCs. (Personally I think it's an improvement.)


There are quite a few usages of #filetoc in user scripts etc., some using it as a way to determine where to inject things I think, so those might break. Would it be worth putting an empty <div id=filetoc> in place, with perhaps a console warning of deprecation?

This is a historic artifact that once introduced has never seen any proper evaluation. Its inconsistent and has long since bothered me, especially as logged in editors hardly even see this thing due to the stockphoto gadget and not a single person has ever complained about that, so it can't be very important to most editors I guess.

I guess mobile users are used to not having ToCs. (Personally I think it's an improvement.)

I don't think it will be a huge problem, but it is something that I think would require a follow up ticket so that we make this consistent.

There are quite a few usages of #filetoc in user scripts etc., some using it as a way to determine where to inject things I think, so those might break. Would it be worth putting an empty <div id=filetoc> in place, with perhaps a console warning of deprecation?

I think that's imperative. We could add a MutationObserver to emit a JS warning I guess. That won't fix everything of course, as some scripts might only use this as a positional anchor, without writing to it. We don't really have ways to deal with deprecations like this, other than doing a lot of outreach.

Proposal: Next week the table of contents at the top of File pages, will be consolidated with the table of content of the page.

@TheDJ can we be specific about which week? Is it this week (week of 27 July) or next week (Week of 3 August)? Please see a modified draft below:

Next week, the table of contents on Wikimedia Commons file pages will be improved by consolidating the file page table of contents with the page table of contents. This will make it easier to understand a file page’s structure, navigate to specific sections, and share links to individual sections.

Proposal: Next week the table of contents at the top of File pages, will be consolidated with the table of content of the page.

Screenshot 2026-06-30 at 20-19-20 File Trins-260617-1640-hu.jpg - Simon04.png (1,083×592 px, 102 KB)

Screenshot 2026-06-30 at 20-18-45 File Trins-260617-1640-hu.jpg - Simon04.png (894×525 px, 113 KB)

Screenshot 2026-06-30 at 20-17-30 File Trins-260617-1640-hu.jpg - Simon04.png (850×462 px, 139 KB)

These make the image itself go out of view, which is IMO a regression. The previous #filetoc was designed to cover as little of the file as possible. Would it be possible to keep the current behavior on skins that include the table of contents in the main body (i.e. all but Vector 2022)? Or to include the table of contents below the image and just provide a skin link (similar to the current #filetoc) above it?

@TheDJ can we be specific about which week? Is it this week (week of 27 July) or next week (Week of 3 August)?

Apparently, neither – the branch cut for the week of 3 August has happened (T430833#12181545), but the changes haven’t been merged yet.

Change #1321675 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/ProofreadPage@master] Put index page link into a paragraph

https://gerrit.wikimedia.org/r/1321675

Change #1306091 merged by jenkins-bot:

[mediawiki/core@master] ImagePage: Integrate the file TOC into the page table of contents

https://gerrit.wikimedia.org/r/1306091

Change #1321675 merged by jenkins-bot:

[mediawiki/extensions/ProofreadPage@master] Put index page link into a paragraph

https://gerrit.wikimedia.org/r/1321675

@Samwilson I’m a bit disappointed this was merged without even reacting to the points I raised two days ago. Before +2’ing, it’s always useful to also look at the attached task(s), not only at the Gerrit comments.

I'm really sorry. I did look at the task but I've had the tab open for too many days and your comment wasn't there (I should've reloaded of course), although I did see the email so that's no excuse. I didn't mean to ignore the points you've raised!

This change is mainly aimed at improving Vector-2022, unfortunately.

I think moving the ToC to be below the image makes lots of sense. And also perhaps getting rid of the 'File' entry, as it's the only one that doesn't equate to an actual heading. If the file stays at the top, there's no point in being able to link to it from the top (considering also that #top still works there).

These make the image itself go out of view, which is IMO a regression. The previous #filetoc was designed to cover as little of the file as possible. Would it be possible to keep the current behavior on skins that include the table of contents in the main body (i.e. all but Vector 2022)? Or to include the table of contents below the image and just provide a skin link (similar to the current #filetoc) above it?

Those screenshots do not represent the latest patch version. Here is one based on mediawiki 2b278482dfef04559dfb2e912857d32575b4441d:

image.png (1,279×930 px, 1 MB)

Those screenshots do not represent the latest patch version. Here is one based on mediawiki

are we sure ? labs seems to indicate otherwise:

Screenshot 2026-08-07 at 10.45.41.png (2,402×1,696 px, 679 KB)

Did take having a local file and doing a purge of the page to show up. I think this is an issue. It's going to cause backlash

are we sure ? labs seems to indicate otherwise:

Screenshot 2026-08-07 at 10.45.41.png (2,402×1,696 px, 679 KB)

Did take having a local file and doing a purge of the page to show up. I think this is an issue. It's going to cause backlash

Err, I was testing a file via Instant Commons, not a local file. You're right.

What's the strategy for non-Vector-2022 skins? Move the TOC below the image? Hide the TOC?

Let's revert for now, until it's clearer what to do.

Let's revert for now, until it's clearer what to do.

Hm, in my opinion the change is very beneficial for the Vector-2022 skin (which is default). If we find (and decide on) a decent solution for the other skins, we're good.

Change #1322683 had a related patch set uploaded (by Simon04; author: Simon04):

[mediawiki/core@master] ImagePage: move TOC element below file link

https://gerrit.wikimedia.org/r/1322683

Change #1322683 had a related patch set uploaded (by Simon04; author: Simon04):

[mediawiki/core@master] ImagePage: move TOC element below file link

https://gerrit.wikimedia.org/r/1322683

image.png (1,131×1,104 px, 951 KB)

Vector-2022 isn't default for all wikis nor all users. But yeah, perhaps moving the ToC below the file is best. But if that can't be done by the next train, then this might (as TheDJ says) perhaps make people annoyed.

I didn't mean to ignore the points you've raised!

Of course. I was sure this was an oversight on your part rather than anything intentional.

This change is mainly aimed at improving Vector-2022, unfortunately.

Yes, and the changes look good there – but only there.

Change #1322683 had a related patch set uploaded (by Simon04; author: Simon04):

[mediawiki/core@master] ImagePage: move TOC element below file link

https://gerrit.wikimedia.org/r/1322683

image.png (1,131×1,104 px, 951 KB)

Or to include the table of contents below the image and just provide a skin link (similar to the current #filetoc) above it?

I think the jump link above the image would be important. The “below file link” can easily go out of view. Example screenshot showing how https://commons.wikimedia.org/wiki/File:No_photo.svg?useskin=vector&uselang=en would look like (I reflected the changes manually, I hope I got them right):

Screenshot 2026-08-08 at 11-19-20 File No photo.svg - Wikimedia Commons.png (1,920×1,088 px, 183 KB)

Do you see the table of contents? With a portrait image, and SDC, it’s below the cut. On a smaller viewport (mine is 1088px high, which I’d call rather large even in today’s standards), not even SDC is needed for the table of contents to go out of view.

There's a grand Commons file page improvements - Google Docs with many ideas.

I (we) cannot improve everything for everybody on everyskin at the same time. I'm happy to work on self-contained tasks (like this is not? :/ ...) and make gradual progress.

This ticket actually predates that design document. Regardless. I think it's a good idea overall. Just needs some clean ups for non-default skins. It could be even some css added to the skin's repo.