Sections
Sections are used to host reusable modules of content that merchants can customize.
Section files are hosted in the sections
directory of the theme.
Liquid in sections
Sections have the same access to global objects, tags, and filters as other Liquid theme files, as well as the following section-specific objects:
- The section object
- The block object
Sections also support the following Liquid tags, which are unique to sections:
Note
Section-specific tags are Liquid tags. However, unlike other tags, section-specific tags don't output their contents or render any Liquid code.
Render a section
You can render sections in one of the following ways:
- Include the section in a JSON template
- Statically render the section with the section Liquid tag
Tip
If you want to render a section inside a template, then use a JSON template. JSON templates provide more extensive customization options for merchants, and improve the theme editor's performance.
Statically render a section
You can statically render a section using the Liquid section tag.
For example, if you have a /sections/header.liquid
file that contains your theme's header content, then you might want to include that section in theme.liquid
so that the header is rendered on all pages that use that layout:
{% section 'header' %}
Note
You can include a statically-rendered section in multiple theme files. However, only one instance of the section exists. If you change section settings in one location, then the change will be applied to all locations where the section is rendered.
Updated over 3 years ago