How can I include one file in another with Shopify?

I'm going through a learning process with my first Shopify theme development. I've customised the bought theme to within an inch of where we want it, now I just want to be able to add a custom section to the Product admin page so I can show a call to action specific for each product. The .liquid file I have created within the Sections folder is cta.liquid and the file I'm trying to include the request to get that file is the product-template.liquid file, also within the Sections folder. Here is my code trying to call the cta.liquid file: {% section 'cta' %} I've also tried using render and include to call the file. With the above arrow I just get this error message on the website: Liquid error (sections/nov-product-template line 161): Could not find asset snippets/cta.liquid The file itself shows no errors. Thanks for any help. Tried using include, render, section, sections. I tried to change the file to the snippets folder but I got an error about schema then

Comment (1)

Jese Leos

August 19, 2024

Verified user

In shopify, you can't render section liquid in the section liquid. so you have to create a new snippet for cta liquid file and include in section liquid. In a word, cta should be snippets/cta.liquid not sections/cta.liquid

You’ll be in good company