Separating Section Block Counts

Topic summary

A user is attempting to implement a show more/show less toggle for section blocks in their store theme.

Current Goal:

  • Display the first 6 section blocks by default
  • Place any additional blocks (7+) inside an expandable/collapsible accordion

Technical Challenge:
The user is struggling with the Liquid templating syntax needed to split section blocks into two groups based on count. They’ve started with a counter variable and a loop through section.blocks, but are uncertain how to:

  • Separate blocks 1-6 from blocks 7+
  • Structure the conditional logic and loop syntax correctly

Current Status:
The code snippet shows an incomplete implementation with reversed/garbled text in comments, suggesting the user is still working through the logic. No solution has been provided yet, and the question remains open regarding the proper Liquid syntax for this block separation pattern.

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

Hoping that someone is able to help me, I am trying to add a show more/show less toggle into a new section.

By default, I will show 6 section blocks but if there are more I’d like to place them in an accordion that will expand/collapse to show the additional items.

{% assign count = 0 %}
{% for block in section.blocks %}
    {% assign count = count | plus: 1 %}
    
        Build Content  1 - 6
    

{% endfor %}
{% if section.blocks.size >= 6 %}

  

        Build Content 7 - End
  

{%  endif %}

So essentially, I think, I will have a loop for 1 through 6 and a section loop through 7 until the end but I am not sure what the syntax is for that.

Right now all 7 are written and a but gets placed, I’m just not sure how (or even if it is possible) to break that section block into 2 pieces based upon an integer, in this case 6.