How to implement conditional sections in 2.0 themes?

Topic summary

Core Issue:
Developers are struggling to implement conditional sections in Shopify 2.0 themes, which was straightforward in 1.0 using Liquid logic to render different sections based on conditions (e.g., product type or customer tags).

Technical Challenge:
Since 2.0 templates are JSON files rather than Liquid files, the previous approach of wrapping {% section %} tags in conditional statements no longer works directly.

Proposed Solutions:

  • Move conditional logic inside the section itself, so sections always load but may not display content
  • Use Ajax/Section Rendering API to dynamically load sections based on conditions
  • Create duplicate section files with identical settings, each including a snippet that handles the rendering logic, then add both sections to the template

Current Status:
The original poster implemented the last approach: moving section code into snippets, creating two sections with different conditional logic for including those snippets, and adding both sections to the template. This workaround functions but isn’t ideal due to duplicated section settings and both sections being present in the template.

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

My initial thought would be to move the conditional logic into the section file