← Back to guides
CodeShopify SectionsSections · Published 2026-11-20 · 3 min read

Build a Shopify Hero Banner Section: Full Liquid, CSS and Schema Code

A complete, ready-to-use Shopify hero banner section with background image, overlay, heading, text, button, alignment and mobile styles. Copy it into sections/.

Share with Shopify developers — useful guides spread faster in theme dev communities.

What you get

One file, sections/hero-banner.liquid, with an image background, dark overlay with adjustable strength, heading, text, button, text alignment and responsive sizes. Everything is editable in the theme editor.

sections/hero-banner.liquid

<section class="hero hero--{{ section.settings.align }}" style="--hero-overlay: {{ section.settings.overlay | divided_by: 100.0 }};">
  {% if section.settings.image != blank %}
    {{ section.settings.image | image_url: width: 1800 | image_tag: class: 'hero__image', loading: 'eager', fetchpriority: 'high', sizes: '100vw', alt: section.settings.heading }}
  {% endif %}
  <div class="hero__content">
    {% if section.settings.heading != blank %}
      <h1 class="hero__title">{{ section.settings.heading | escape }}</h1>
    {% endif %}
    {% if section.settings.text != blank %}
      <p class="hero__text">{{ section.settings.text | escape }}</p>
    {% endif %}
    {% if section.settings.button_label != blank and section.settings.button_link != blank %}
      <a class="hero__button" href="{{ section.settings.button_link }}">{{ section.settings.button_label | escape }}</a>
    {% endif %}
  </div>
</section>

{% style %}
  #shopify-section-{{ section.id }} .hero { position: relative; min-height: {{ section.settings.height }}px; display: flex; align-items: center; color: #fff; overflow: hidden; }
  #shopify-section-{{ section.id }} .hero__image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  #shopify-section-{{ section.id }} .hero::before { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, var(--hero-overlay)); z-index: 1; }
  #shopify-section-{{ section.id }} .hero__content { position: relative; z-index: 2; max-width: 640px; padding: 40px 24px; margin: 0 auto; }
  #shopify-section-{{ section.id }} .hero--left .hero__content { margin-left: 0; text-align: left; }
  #shopify-section-{{ section.id }} .hero--center .hero__content { text-align: center; }
  #shopify-section-{{ section.id }} .hero--right .hero__content { margin-right: 0; text-align: right; }
  #shopify-section-{{ section.id }} .hero__title { font-size: clamp(30px, 5vw, 56px); line-height: 1.1; margin: 0 0 12px; }
  #shopify-section-{{ section.id }} .hero__text { font-size: 18px; margin: 0 0 24px; }
  #shopify-section-{{ section.id }} .hero__button { display: inline-block; background: #fff; color: #111; padding: 14px 30px; border-radius: 999px; font-weight: 700; text-decoration: none; }
  @media (max-width: 749px) { #shopify-section-{{ section.id }} .hero { min-height: {{ section.settings.height | times: 0.7 | round }}px; } }
{% endstyle %}

{% schema %}
{
  "name": "Hero banner",
  "settings": [
    { "type": "image_picker", "id": "image", "label": "Background image" },
    { "type": "text", "id": "heading", "label": "Heading", "default": "Discover the new collection" },
    { "type": "textarea", "id": "text", "label": "Text", "default": "Fresh styles with free delivery over $50." },
    { "type": "text", "id": "button_label", "label": "Button label", "default": "Shop now" },
    { "type": "url", "id": "button_link", "label": "Button link" },
    { "type": "select", "id": "align", "label": "Text alignment", "default": "center",
      "options": [{ "value": "left", "label": "Left" }, { "value": "center", "label": "Center" }, { "value": "right", "label": "Right" }] },
    { "type": "range", "id": "overlay", "label": "Overlay strength", "min": 0, "max": 80, "step": 5, "unit": "%", "default": 40 },
    { "type": "range", "id": "height", "label": "Section height", "min": 300, "max": 800, "step": 20, "unit": "px", "default": 520 }
  ],
  "presets": [{ "name": "Hero banner" }]
}
{% endschema %}

How to install

  1. Online Store, Themes, Edit code (on a duplicate theme).
  2. Sections, Add a new section, name it hero-banner, paste and save.
  3. Customize, Add section, choose Hero banner.

Performance tips

  • The hero image loads eagerly with high fetch priority, because it is usually the largest visible element.
  • Upload an image around 1800px wide. Shopify serves smaller sizes automatically.

Takeaway

Copy, paste and customize. To turn your own design into a section instead, use the converter, and follow the Shopify section tutorial. See also the FAQ accordion section.

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

Shopify Sections

OS 2.0 sections, JSON templates, and section architecture.

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.