Skip to content

Accessibility checkers have a problem with the placement of the h1 tag #11261

@mclarty

Description

@mclarty

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Accessibility checkers (such as SiteImprove) are flagging each page using the blog layout as not adhering to "accessibility best practices" with the following note:

Page does not start with a level 1 heading
A level 1 heading h1 tells the user what the page is about before they decide to navigate through the content.

Headings are used to structure content into a hierarchy of importance. If a page starts with a different heading level, it can cause confusion for the user.

When analyzing the HTML output from Docusaurus, the sidebar (aside) is rendered before the main content (main) and the h3 tag in the sidebar is being detected as the first header in the HTML source. By removing the use of h3 in the sidebar and replacing with a div class specific to the sidebar, accessibility checkers (and screen readers and other assistive devices) will see the use of h-tags in the main content as the only actual headings on the page.

Source example below:

<div class="row">
    <aside class="col col--3">
        <nav class="sidebar_re4s thin-scrollbar" aria-label="Blog recent posts navigation">
            <div class="sidebarItemTitle_pO2u margin-bottom--md">Recent posts</div>
            <div role="group">
                <h3 class="yearGroupHeading_rMGB">2025</h3>
                <ul class="sidebarItemList_Yudw clean-list">

                	[...]

                </ul>
            </div>
        </nav>
    </aside>
    <main class="col col--7">
        <article class="margin-bottom--xl">
            <header>
                <h2 class="title_f1Hy"><a href="/blog/item1/">Article Title</a></h2>

                [...]

            </header>
            <div class="markdown">
                <p>Article body.</p>
            </div>

            [...]

        </article>
    </main>
</div>

Related to this -- the blog index page does not contain an h1 tag altogether.

Reproducible demo

No response

Steps to reproduce

  1. Publish a Docusaurus site using docusaurus-theme-classic and create a blog page.
  2. Review the HTML code.

Expected behavior

The first header tag on a blog page should be an h1 that conveys the article title.

An h1 tag on the blog index (e.g., recent posts) page should be an h1 that conveys the page title.

Actual behavior

The first header tag to occur on the blog pages is an h3 in the sidebar.

No h1 tag exists on the blog index page.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiondomain: a11yRelated to accessibility concerns of the default theme

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions