Skip to content

section

Renders a section by its file name, without the .liquid extension. This is known as statically rendering a section.

liquid
{% section 'header' %}

The example above renders sections/header.liquid.

Static sections are most often used in layouts for parts that appear on every page, such as the header, footer, and announcement bar.

Argument

  • name: The section file name, without the .liquid extension. Must be a quoted string literal.

Variables aren't supported:

liquid
{% assign name = 'header' %}
{% section name %} {%- comment -%} Doesn't work {%- endcomment -%}

If no section file matches the name, the tag renders nothing instead of raising an error.

Behaviour

A statically rendered section differs from one added through a JSON template:

  • Fixed placement: sellers can't add, remove, or reorder it, because its position is set in the Liquid file.
  • Global settings: its settings and blocks come from the config/settings_data.json file, matched by the section's type. The same data is used everywhere the section is rendered.
  • Single configuration: because that data is global, rendering the section in more than one place shows the same content each time. To place a section more than once with different settings, add it to a JSON template instead.

Example

liquid
<body>
  {% section 'announcement-bar' %}
  {% section 'header' %}

  {{ content_for_layout }}

  {% section 'footer' %}
</body>