Blog

Shopify Liquid Accessibility: Patterns for Theme Developers

TestParty
TestParty
November 28, 2026

Last updated: November 28, 2026

Shopify Liquid accessibility is decided at render time, not in a design review: every `{% for %}` loop, every `{{ image.alt }}` fallback, and every schema setting produces the exact HTML a screen reader parses, so a snippet bug is a WCAG failure shipped to every page that includes it. This guide covers the Liquid-specific patterns that hold up under a real audit β€” image fallbacks, unique IDs inside loops, schema-driven defaults, and where ARIA belongs versus where it doesn't.

Key numbers: Shopify's Theme Store requirements map to only 16–22% of WCAG 2.2's 86 in-force success criteria (shopify.dev). A stock Dawn theme ships 30–100 detectable violations out of the box; premium themes typically carry 100–350 (TestParty analysis, 2026). TestParty's detection stack runs 60–70% automated, 30% manual β€” a scanner confirms a `for`/`id` pair exists, not that the label makes sense (TestParty internal data).

Why does accessibility live in your Liquid?

Liquid is the layer that decides what reaches the accessibility tree β€” a flawless design can still fail an audit if the snippet rendering it drops a label, an ID, or an alt attribute. Assistive technology never sees a `.liquid` file; it only sees the HTML that file produces.

Shopify's Theme Store review checks only 16–22% of WCAG 2.2's success criteria β€” a minimum Lighthouse score and basic contrast, not focus management, ARIA correctness, or whether a `for`/`id` pair still points at the right control after a refactor. Everything outside that 16–22% is the developer's responsibility, inherited the moment a merchant installs the theme. In TestParty's audits of Shopify theme codebases, the same handful of snippet patterns account for most of what a later audit flags.

What are the core Liquid patterns for images?

The core Liquid image pattern is a fallback chain that never lets `alt` render empty by accident β€” wrong the instant it's applied to a decorative element, which needs an explicit empty string instead.

Shopify exposes image data through the `media` object, whose four `media_type` values mean a media loop has to branch, not just print an `<img>` for everything it iterates over:

{% comment %} Fixes WCAG 1.1.1 β€” decorative param skips the title fallback so cosmetic elements get alt="", not a repeated product name. {% endcomment %}
{% if decorative %}
  <img src="{{ media | image_url: width: 100 }}" alt="" role="presentation">
{% else %}
  <img src="{{ media | image_url: width: 800 }}" alt="{{ media.alt | default: product.title | escape }}" loading="lazy">
{% endif %}

Applying that fallback everywhere, with no decorative branch, is the most common shared-snippet mistake. A video or 3D model pushed through the same `<img>` tag renders a broken thumbnail, so branch on `media_type` instead of assuming every item is a photo:

{% comment %} Fixes WCAG 1.1.1 β€” non-image media gets a labeled control instead of a broken <img>. {% endcomment %}
{% for media in product.media %}
  {% if media.media_type == 'image' %}
    <img src="{{ media | image_url: width: 800 }}" alt="{{ media.alt | default: product.title | escape }}">
  {% else %}
    <button type="button" aria-label="{{ media.media_type | capitalize }}: {{ media.alt | default: product.title | escape }}">
      <img src="{{ media.preview_image | image_url: width: 800 }}" alt="" role="presentation">
    </button>
  {% endif %}
{% endfor %}

For writing alt text well, and bulk-fixing it across a catalog, see Shopify product image alt text.

How do you label controls generated in loops?

A control generated inside a loop needs an ID unique to that rendered instance, not just unique within the template file β€” `section.id` and `block.id` make that possible, assigning a fresh value each time a section or block repeats.

A hardcoded `id="Quantity"` works on one product page, then breaks once the same snippet renders twice β€” a main form and a quick-view modal, say. A browser resolves `for` to the first matching `id`, so the second instance's label silently points at the first:

{% comment %} Fixes WCAG 4.1.2 β€” a duplicate id/for pair leaves the second control's label pointing at the first one it finds. {% endcomment %}
<label for="Quantity-{{ section.id }}" class="visually-hidden">Quantity</label>
<input type="number" id="Quantity-{{ section.id }}" name="quantity" value="1" min="1">

<label for="NewsletterEmail-{{ block.id }}">Email address</label>
<input type="email" id="NewsletterEmail-{{ block.id }}" name="contact[email]" required>

The same collision hits `name`: two radio groups sharing one `name` act as a single group, so picking a value in a quick-view modal silently overrides the main form behind it β€” the fieldset-and-radio markup itself can be correct (see accessible variant swatches on Shopify) and still misbehave once duplicated:

{% comment %} Fixes WCAG 4.1.2 β€” suffixes the radio group's name with section.id so a duplicated fieldset doesn't share state with the original. {% endcomment %}
<fieldset>
  <legend>{{ option.name }}</legend>
  {% for value in option.values %}
    <label>
      <input type="radio" name="{{ option.name }}-{{ section.id }}" value="{{ value | escape }}"
        {% if value == option.selected_value %}checked{% endif %}>
      {{ value }}
    </label>
  {% endfor %}
</fieldset>

Suffix every `id`, `for`, and `name` with `section.id` or `block.id` the moment a snippet might render more than once on a page, even if today it never does.

How do you build accessible section settings?

A section schema is where a merchant overrides the developer's decisions, and a setting with no accessible default is one a merchant will eventually use to break the page: a color picker with no contrast guidance, an autoplay toggle defaulting on, a heading level hardcoded for a layout the section won't always sit in.

Three defaults do most of the work: autoplay off (WCAG 2.2.2 Pause, Stop, Hide); heading level as a `select` setting instead of hardcoded `<h2>`, since a reused section can otherwise break the outline; and an alt-text override on every `image_picker`, since Files-admin alt text is often blank:

{
  "name": "Featured collection",
  "settings": [
    { "type": "checkbox", "id": "autoplay", "label": "Autoplay slideshow", "default": false },
    {
      "type": "select",
      "id": "heading_level",
      "label": "Heading level",
      "options": [
        { "value": "h2", "label": "Heading 2" },
        { "value": "h3", "label": "Heading 3" }
      ],
      "default": "h2"
    }
  ]
}

The same pattern extends to blocks: pair every `imagepicker` with a plain `text` setting for an alt override. None of this stops a merchant from pairing colors with no contrast β€” the real argument for building sections around a theme's shared `colorscheme` presets instead of independent color pickers, since a preset is checked for contrast once and reused everywhere.

What ARIA belongs in Liquid β€” and what doesn't?

Server-rendered ARIA is state Liquid already knows at build time β€” which nav link matches the current page, which pagination part is current β€” and belongs in the template. State that only exists after a shopper acts belongs in JavaScript instead.

`aria-current` is the clearest server-side case: Liquid already has a link's URL to compare against `request.path`, and already knows whether a pagination `part` is a link at all:

{% comment %} Fixes WCAG 4.1.2 β€” marks the current nav item and pagination part for assistive tech, entirely server-side. {% endcomment %}
<nav aria-label="Primary">
  {% for link in linklists.main-menu.links %}
    <a href="{{ link.url }}" {% if link.url == request.path %}aria-current="page"{% endif %}>{{ link.title }}</a>
  {% endfor %}
</nav>
{% paginate collection.products by 24 %}
  <nav aria-label="Pagination">
    {% for part in paginate.parts %}
      {% if part.is_link %}<a href="{{ part.url }}">{{ part.title }}</a>{% else %}<span aria-current="page">{{ part.title }}</span>{% endif %}
    {% endfor %}
  </nav>
{% endpaginate %}

`aria-expanded`, by contrast, has no business in a template β€” its value changes the moment a shopper clicks something, after Liquid has already rendered. Liquid owns any attribute fixed at load; JavaScript owns whatever changes after. A live-region container follows the same logic in reverse β€” it must exist empty in the rendered HTML for a screen reader to notice it later:

{% comment %} Fixes WCAG 4.1.3 β€” the container ships empty so the first JS update actually announces; aria-expanded stays out, since JS owns that state. {% endcomment %}
<button type="button" aria-controls="PredictiveSearchResults-{{ section.id }}">Search</button>
<div id="PredictiveSearchResults-{{ section.id }}" aria-live="polite" class="visually-hidden"></div>

TestParty's audits of Dawn-based stores flag this exact gap most often on search and cart-drawer components: a live region added to a container JavaScript replaces wholesale instead of updating in place, unmounting it before it fires. See ARIA labels for ecommerce for the fuller component-by-component reference this section doesn't repeat.

How do you keep templates accessible across updates?

Shopify's own theme linter, Theme Check, catches Liquid syntax errors, deprecated tags, and unused variables β€” not accessibility, which is the gap every workflow below has to cover some other way.

That means linting has to happen at the rendered-output layer, not the source layer β€” a tool reading `.liquid` text catches a missing `alt` but not computed contrast or whether a live region fires; see accessibility linters: catch issues before they ship for the full split. PreGame, TestParty's editor extension, closes part of the source-side gap for Liquid, proposing the fixed line instead of only flagging it. Disclosure: TestParty builds PreGame, so weigh this as vendor description, not a recommendation.

The gate that matters for a theme repo runs against a rendered preview, not source β€” Liquid that lints clean can still render broken HTML once real data flows through it:

# Pushes an unpublished theme, runs axe-core against the resulting preview URL.
shopify theme push --unpublished --theme "CI Preview $(date +%s)" --json > preview.json
npx @axe-core/cli "$(jq -r '.preview_url' preview.json)" --exit

The last discipline: treat every theme update as a re-scan trigger, since an update can pull in a new default snippet and silently overwrite a fix never captured in a documented diff. See accessibility in CI/CD for the full pipeline this gate is one stage of.

What are the five Liquid smells that predict audit failures?

Five snippet-level patterns predict most of what a later audit finds, and each is visible in a code review β€” no rendered page or scanner run required.

Liquid smellWhy it failsWCAGOne-line fix
Raw, unescaped output in an attributeBreaks the attribute on a stray quote or ampersand1.1.1Pipe the value through `escape`
Hardcoded IDs in a snippet rendered twiceThe second `for`/`id` points at the first4.1.2Suffix ids with `section.id` or `block.id`
A click-handler `<div>` copied into a new snippetNo name, role, or keyboard support ships either2.1.1 / 4.1.2Start from a native `<button>` or `<input>`
Heading level hardcoded per sectionA reused section can break the outline1.3.1Expose heading level as a `select` setting
Icon-only link with no text alternativeAnnounces "link," never what the control does4.1.2Add a visually-hidden span or `aria-label`

Catching these five in review is cheaper than any later fix: a reviewer spots a raw `{{ image.alt }}` output or a `<div onclick>` in seconds, while the same defect surfaces in an audit only after shipping to every page that includes the snippet.

Frequently Asked Questions

Does the `default` filter catch every missing alt text case? No. It only fires when a value is `nil`, `false`, or an empty string β€” it does nothing for an alt attribute already set to a bad value, like a filename or a title repeated across nine gallery photos.

Can Theme Check be extended to catch accessibility issues? Not meaningfully as of 2026. Its rule set targets syntax, deprecated tags, and performance, not accessibility β€” the gap dev-time tools like PreGame and CI-stage scanners exist to cover instead.

Why does a contrast bug appear after a theme update if no templates changed? Color values usually live in schema settings, not the template β€” an update can add a new default color scheme or shift a preset's values, interacting with a merchant's existing colors without a single Liquid file changing.

Is server-rendered ARIA enough, or does every component still need JavaScript testing? No. It covers only state Liquid knows at render time. Anything that changes after a shopper interacts β€” a menu opening, a filter applying β€” still needs a keyboard and screen-reader pass, which a code review of the Liquid alone can't verify.

Built with TestParty's cyborg approach β€” AI-powered research combined with human accessibility expertise. This article contains TestParty's editorial analysis based on publicly available information. We're an accessibility vendor with opinions informed by working with 100+ brands, and we encourage readers to do their own due diligence when evaluating any solution.

Stay informed

Accessibility insights delivered
straight to your inbox.

Contact Us

Automate the software work for accessibility compliance, end-to-end.

Empowering businesses with seamless digital accessibility solutionsβ€”simple, inclusive, effective.

Book a Demo