Dynamic Liquid Variable inside Liquid tag?

63 0 13

Hi there.

Not sure if this is possible, but i am looking for a way to dynamically pull in page content based on which product is being viewed.

I was hoping i'd be able to create pages with the same handles as the products and then include the page content on the product page using something like -

{{ pages.DYNAMIC-PRODUCT-HANDLE.content }}

I have tried putting the liquid tag inside like this, but this doesn't work -

{{ pages.{{product.handle}}.content }}

I have also tried to capture the product URL and then use it, but with no luck.

Does anyone know if what i am trying to do is possible, or if there is another way to do it? Could use an iFrame, but would prefer not to.

Any help or suggestions would be much appreciated!



63 0 13

Ah ha i think i have answered my own question.


This seems to do the job -

{% capture foo %}{{ product.handle }}{% endcapture %}

Shopify Expert
9811 92 1561

Or just this:

{{ pages[product.handle].content }}

My typo was picked up in the post below. It's fixed now!

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
63 0 13

Thanks Jason..

I should have realised that was the simplest way after i found out that using square brackets was the way to do it!

Just in case anyone else wants to use it.. it will need to be product.handle rather than product-handle.. like this -

{{ pages.[product.handle].content }}

Hi Jason,

Could you help me understand why it's not working in this case:


{{ section.blocks[0].settings.main_img[forloop.index] | img_url: '200x' }}

I have multiple ids in my schema tags, named "main_img1", "main_img2" etc.

• I checked, "forloop.index" returns "1" in the first loop (linklists loop).

• When I manually replace [forloop.index] with "1", it's working, so it's definitely an issue with the above code.

Where did I fail here?
Thank you

C'est simple comme bonjour ! Ou presque.
Need some help to customize your website? Message me anytime: 5euros.com/profil/maxdesign