Shopify Liquid fix

Before and after

Broken — before
{%- comment -%} layout/theme.liquid (Broken: generic <div> wrapper, no <main> landmark) {%- endcomment -%}
<body>
  {% sections 'header-group' %}
  <div id="MainContent" class="content-for-layout">
    {{ content_for_layout }}
  </div>
  {% sections 'footer-group' %}
</body>
Fixed — after
{%- comment -%} layout/theme.liquid (Fixed: single <main> landmark + Skip-to-Content link) {%- endcomment -%}
<body>
  <a class="skip-to-content-link visually-hidden" href="#MainContent">
    {{ 'accessibility.skip_to_text' | t | default: 'Skip to content' }}
  </a>

  {% sections 'header-group' %}

  <main id="MainContent" class="content-for-layout focus-none" tabindex="-1">
    {{ content_for_layout }}
  </main>

  {% sections 'footer-group' %}
</body>
Live preview

Fixed vs. broken example

Passes landmark-one-main
Accessibility tree: Landmarks list: banner (<header>), main (<main id="main-content">)

Pair your single <main id="main-content" tabindex="-1"> landmark with a visible-on-focus "Skip to main content" link at the top of <body>.

Automated test

Playwright + axe-core check

tests/a11y-landmark-one-main.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("Shopify theme.liquid renders exactly one <main> landmark", async ({ page }) => {
  await page.goto("/");
  await expect(page.getByRole("main")).toHaveCount(1);
  const results = await new AxeBuilder({ page })
    .withRules(["landmark-one-main"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

Missing or duplicate <main> tags inside layout/theme.liquid trigger on 100% of storefront URLs—home, products, collections, cart, and blogs. A11yDrift highlights it as a single root layout edit.

Screen readers

What NVDA and VoiceOver announce

Keyboard and screen-reader users rely on the <main> landmark (and Skip-to-Content links targeting it) to bypass 30+ repeating header, mega-menu, and announcement links on every page navigation.

NVDA (Windows)

Broken

Pressing D (next landmark) announces: "no next landmark"


Fixed

Pressing D jumps straight past navigation and announces: "main landmark"

VoiceOver (macOS / iOS)

Broken

Landmarks rotor shows no Main region; user must step through every header link.


Fixed

Landmarks rotor lists "main", letting the user jump directly to primary content.

Common questions

Why put tabindex='-1' on <main id='MainContent'> in Shopify?
Adding tabindex='-1' ensures browsers reliably move keyboard focus into <main> when a shopper activates the 'Skip to content' anchor link, without adding <main> into the normal Tab order.
What if a Shopify landing-page app (PageFly/Shogun) injects a second <main>?
Nested or duplicate <main> elements also fail landmark-no-duplicate-main. Change the inner section container to <div class='page-section'> so layout/theme.liquid owns the sole <main> landmark.
Does Shopify's Skip-to-Content link need to become visible on keyboard focus?
Yes—style .skip-to-content-link:focus-visible to pull it visibly into the top-left viewport with strong contrast so sighted keyboard users can see and activate it.