Pass a variable as a section name

New Member
2 0 0

I'm trying to display a section by passing the name as a variable but get the following error:


Liquid error: Error in tag 'section' - '{{showsect1}}' is not a valid section type


I'm using the following two pieces of code. This is at the top (to concatenate the product sku with "section1", eg "MySKUsection1)":

{%- assign sect1= "section1" -%}

{% capture showsect1 %}
{{ current_variant.sku }}{{ sect1 }}
{% endcapture %}


This where I want to open the section on a page:


<div class="page-width">
{% section '{{showsect1}}' %}


I've used <SPAN> to check the output and it's correct.  If I hard code and pass section manually it also works {% section 'mysectionname' %}


I'm guessing it's a problem passing showsect1 as a variable, any ideas greatly appreciated, i've been looking at this for 4 hours :(



Shopify Expert
2721 460 598

Hi @dash99 

Sorry but you cant do this, because you are trying to add section in side other section that cant possible. We can not add section inside other section.

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here