Collapsible row content

Topic summary

A user is implementing multiple collapsible rows on a Shopify product page to accommodate large amounts of product variant content (each row limited to 50kb). They’ve written conditional logic to display variant-specific content, but empty collapsible rows still appear even when no matching variant title exists.

The Problem:

  • Collapsible rows render even when empty
  • Duplicate section names (“Bienfaits de la pierre”) appear when only one is desired
  • The user shared code snippets and a Google Sheets link showing the issue

Recommended Solution:
A respondent advises against embedding large content directly in theme files and suggests:

  • Use metafields or metaobjects instead
  • Leverage dynamic sources to avoid complex if/else logic
  • Implement advanced theme customization to check if content is blank before rendering the collapsible UI
  • Wrap the entire collapsible logic in a condition like {% if variable != blank %}...{% endif %}

The core issue requires theme-level customization to conditionally hide empty collapsible sections.

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

Hello, I created several collapsible rows because each one can not exceed 50kb and I have a lot of text because I have a lot of products and variants. To be sure each product has its own content, and not the same for all the products because each product is unique, I modified the code. Indeed, I wrote this in each collapsible-row (look below). But, even if a variant title isn’t written in the collapsible row, the collapsible row appears. It is empty, but it appears and I don’t want that because I have two collapsible rows that have the same name ‘Bienfaits de la pierre’ and I just want one. How can I do ? (There is no duplicate content in any of the collapsible rows and I think the code is good.). Here is a link to a picture of my problem https://docs.google.com/spreadsheets/d/1zGkTOY0wcV0W8rff9AriXYp1RNvfCq_Bz1lKLdNbhMM/edit?usp=sharing

Here is my code in the collapsible-row :

{% if product.title == ‘xxx’ %}

{% assign variant = product.selected_or_first_available_variant %}

{% if variant.title == ‘xxx’ %}

xxx

{% elsif variant.title == ‘xxx’ %}

xxx

{% elsif product.title == ‘xxx’ %}

{% assign variant = product.selected_or_first_available_variant %}

{% if variant.title == ‘xxx’ %}

{% elsif variant.title == ‘xxx’ %}

xxx

{% endif %}

{% endif %}

Hi @Leachapuis :waving_hand:

Hello, I created several collapsible rows because each one can not exceed 50kb

Making content live inside a theme is to be avoided.

Use metafields or metaobjects, or in some case pages content, or liquid snippets.

Or for some sections/blocks/settings use dynamic sources, no if/else logic needed

https://help.shopify.com/en/manual/online-store/themes/theme-structure/sections-and-blocks#metafields-and-dynamic-sources

That requires an advanced theme customization to check if the content is blank or not and allow/disallow the collapsible UI from rendering.

crudely it’s a matter of wrapping the entire logic in a condition: {% if variable != blank %}… {% endif %}

If you need that customization then contact me for services,

Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.