How to Use Sections Everywhere in Shopify OS 2.0 Themes

Published on Jun 17, 2024

By Michael Chen

#Shopify#E-commerce#Web Development
Content multiethnic female coworkers at table with flowers surfing tablet while choosing design for bouquet during work in florist shop

Shopify’s Online Store 2.0 (OS 2.0) introduced a powerful feature called “sections everywhere,” allowing merchants to add dynamic, customizable content blocks to various pages of their online stores. However, some users have encountered challenges when trying to implement this functionality, particularly with certain themes. In this comprehensive guide, we’ll explore how to add sections to page templates in Shopify OS 2.0 themes, with a focus on troubleshooting common issues and maximizing the potential of your store’s design.

Understanding Sections in Shopify OS 2.0

What are Sections?

Sections in Shopify are modular, customizable content blocks that can be added to different pages of your online store. They allow for greater flexibility in design and layout, enabling merchants to create unique and engaging shopping experiences without the need for extensive coding knowledge.

The Promise of “Sections Everywhere”

With the introduction of OS 2.0, Shopify promised the ability to use sections on all pages of a store, not just the homepage. This feature was meant to give merchants unprecedented control over their store’s appearance and functionality across various page types.

Common Misconceptions

Many users assume that all OS 2.0 themes automatically support sections on every page. However, as we’ll discover, this isn’t always the case, and some additional configuration may be required.

Troubleshooting Section Availability in OS 2.0 Themes

Identifying the Issue

When working with an OS 2.0 theme like Empire, you might encounter a situation where creating a new page template doesn’t display the expected section options. Instead, you may see a message stating, “No theme sections available for this template.”

The Root Cause

The primary reason for this issue is that each section in a theme needs to be explicitly configured to be available on specific page types. This is controlled through the section’s schema, which defines where the section can be used.

The Solution

To resolve this issue and make sections available on page templates, you need to modify the section’s liquid file. Here’s the key step:

  1. Locate the section’s liquid file you want to make available on page templates.
  2. Scroll to the bottom of the file and find the {% schema %} tag.
  3. Within the schema, look for the "templates" array.
  4. Add "page" to the list of templates, like this:
{% schema %}
{
  // ... other schema properties ...
  "templates": [
    "index",
    "product",
    "page"
  ]
}
{% endschema %}

By adding "page" to the templates list, you’re telling Shopify that this section should be available for use on page templates.

Implementing Sections Across Different Page Types

Home Page Sections

Most themes come with a variety of sections pre-configured for the home page. These often include hero banners, featured products, collection lists, and more. Ensure that your desired sections have "index" in their templates list to use them on the home page.

Product Page Sections

To enhance your product pages with custom sections, make sure to include "product" in the templates list of the relevant section files. This allows you to add features like related products, custom product tabs, or additional information blocks.

Collection Page Sections

For collection pages, you’ll want to add "collection" to the templates list. This enables you to create dynamic layouts for your product categories, potentially including featured items, collection descriptions, or filtering options.

Advanced Section Configuration

Creating Custom Section Presets

To make your sections more easily accessible when building pages, you can create presets. Add a "presets" block to your section schema like this:

{% schema %}
{
  "name": "Custom Section",
  "settings": [
    // ... your settings ...
  ],
  "presets": [
    {
      "name": "My Custom Section"
    }
  ]
}
{% endschema %}

This preset will appear in the section selector when editing pages, making it quicker to add your custom sections.

Utilizing Section Settings

Take full advantage of section settings to create flexible, reusable content blocks. You can define various types of settings such as text fields, image pickers, and color selectors to allow for easy customization without touching code.

Optimizing Section Performance

When creating complex sections, be mindful of performance. Avoid nested loops and excessive liquid logic that could slow down page load times. Consider using JavaScript for dynamic elements that don’t need to be rendered server-side.

Best Practices for Section Management

Consistent Naming Conventions

Adopt a clear naming convention for your sections to make them easily identifiable in the theme editor. This is especially important as your store grows and accumulates more custom sections.

Documentation and Comments

Include comments in your section liquid files to explain complex logic or customization options. This will be invaluable for future maintenance or when collaborating with other developers.

Regular Theme Updates

Keep your theme up to date with the latest version provided by the theme developer. New updates often include improvements to section functionality and compatibility with Shopify’s latest features.

By following these guidelines and understanding the intricacies of section configuration in Shopify OS 2.0 themes, you can unlock the full potential of “sections everywhere” and create a truly customized and dynamic online store experience. Remember that while some initial setup may be required, the flexibility and control you gain over your store’s design are well worth the effort.

Take Our Quick Quiz:

Which primary product image do you think has the highest conversion rate?