Build a Shopify FAQ Accordion Section: Full Liquid, CSS and Schema Code
A ready-to-use Shopify FAQ accordion with blocks, no JavaScript needed, using the native details element. Copy the section file and add it to your theme.
Share with Shopify developers — useful guides spread faster in theme dev communities.
What you get
An accessible FAQ built with the native <details> and <summary> elements. Merchants add, remove and reorder questions as blocks, and the section outputs FAQ structured data for search engines.
sections/faq-accordion.liquid
<section class="faq">
{% if section.settings.title != blank %}
<h2 class="faq__title">{{ section.settings.title | escape }}</h2>
{% endif %}
{% for block in section.blocks %}
<details class="faq__item" {{ block.shopify_attributes }}{% if forloop.first and section.settings.open_first %} open{% endif %}>
<summary class="faq__question">{{ block.settings.question | escape }}</summary>
<div class="faq__answer">{{ block.settings.answer }}</div>
</details>
{% endfor %}
</section>
{% if section.blocks.size > 0 %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{%- for block in section.blocks -%}
{
"@type": "Question",
"name": {{ block.settings.question | json }},
"acceptedAnswer": { "@type": "Answer", "text": {{ block.settings.answer | strip_html | json }} }
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
</script>
{% endif %}
{% style %}
#shopify-section-{{ section.id }} .faq { max-width: 760px; margin: 0 auto; padding: 48px 20px; }
#shopify-section-{{ section.id }} .faq__title { text-align: center; margin: 0 0 24px; }
#shopify-section-{{ section.id }} .faq__item { border-bottom: 1px solid #e2e8f0; }
#shopify-section-{{ section.id }} .faq__question { cursor: pointer; font-weight: 600; padding: 16px 28px 16px 0; list-style: none; position: relative; }
#shopify-section-{{ section.id }} .faq__question::-webkit-details-marker { display: none; }
#shopify-section-{{ section.id }} .faq__question::after { content: "+"; position: absolute; right: 4px; top: 14px; font-size: 22px; }
#shopify-section-{{ section.id }} .faq__item[open] .faq__question::after { content: "\2212"; }
#shopify-section-{{ section.id }} .faq__answer { padding: 0 0 16px; color: #475569; line-height: 1.7; }
{% endstyle %}
{% schema %}
{
"name": "FAQ accordion",
"max_blocks": 20,
"settings": [
{ "type": "text", "id": "title", "label": "Title", "default": "Frequently asked questions" },
{ "type": "checkbox", "id": "open_first", "label": "Open first question", "default": true }
],
"blocks": [
{
"type": "question",
"name": "Question",
"settings": [
{ "type": "text", "id": "question", "label": "Question", "default": "How long does delivery take?" },
{ "type": "richtext", "id": "answer", "label": "Answer", "default": "<p>Orders arrive in 2 to 4 working days.</p>" }
]
}
],
"presets": [{ "name": "FAQ accordion", "blocks": [{ "type": "question" }, { "type": "question" }, { "type": "question" }] }]
}
{% endschema %}
Why this works
- No JavaScript: the browser handles opening and closing.
- Accessible: keyboard and screen readers understand
details. - Editor friendly:
block.shopify_attributeskeeps each question selectable, see this guide. - SEO: the JSON-LD helps search engines understand the questions.
Takeaway
Paste the file, add a few questions and publish. Learn more about blocks in the Dynamic Shopify blocks guide and compare patterns in Flat vs Block Sections.
Try it with our free tools
Paste your HTML into the HTML to Liquid converter to generate a section with schema, or pick a layout from Ready Sections. Questions? Use the contact form.
Topic cluster
Dynamic Blocks
Repeatable blocks, sliders, FAQs, and merchant-managed rows.
Convert your HTML to Shopify Liquid
Paste a module, generate Liquid + schema, then copy the result into your theme. Free to try—no signup required for a sample conversion.
Share
Share this guide
Found this guide useful? Share it with other Shopify developers on LinkedIn, X, or Reddit.