Skip to content

Improvement: A user should be able to exclude headings from the ToC block in the editor. #69200

@gmovr

Description

@gmovr

What problem does this address?

In the ToC block, there is currently no way to exclude a specific heading from the list. I'm aware of two workarounds, but neither is good, and they both have drawbacks:

  • Using a span or non-heading element to render a heading. This is not semantically correct and could also impact SEO
  • Converting the ToC to a static list. This presents another issue, e.g., if new headings are added or the IDs change, the ToC will be out of sync.

One use case would be very long articles, meaning a long ToC. However, I can also see this feature being useful for cases where a heading is not "ToC worthy" but we still want to retain the article's semantic hierarchy.

What is your proposed solution?

I've outlined a solution in #69063, but after discussing it briefly with @swissspidy, I realized it seems a bit out of scope for the current PR. Also, I think more discussion on the specific UI could be helpful.

My solution relies on a class assigned to the heading, which is simple but also opaque if you don't read the code.

I will remove this functionality from #69063 to align it with the scope of #51605 and open a new PR with my suggestion to exclude headings to cover the issue you're reading now.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions