Shopify Help with sections.

PinkHat
New Member
2 0 0

Hi,

I am new to theme building but have a basic knowledge of web development and my concern is that when i create a theme with 2-3 same type sections like "2 image overlay with text and 2 custom content section" then when i see in edit code that there is a common file for both custom sections and if i want and try to edit one i can see those edits on both sections.

How do i overcome this if i just want to change a single section ?

Thanks

 

P.S - New to Shopify

0 Likes
gina-gregory
Shopify Expert
710 47 168

If I'm reading your post correctly, it sounds like you're running into the 'static' nature of sections not on the home page. Any sections built for internal pages cannot be re-used for different content from page to page. Please have a look at this page describing the difference between Static and Dynamic sections: https://help.shopify.com/en/manual/online-store/os/using-themes/change-the-layout/theme-settings/sec... There is no direct fix for this at the moment. It's worth noting that Shopify is actively working on changing this though (dubbed 'Sections Everywhere'). You could use a page builder app in the meantime.

Eric_Seastrand
Shopify Partner
44 3 40

To expand on Gina's comment: you can work around some of those limitations by simply copy/pasting your sections into separate liquid files (ie, multiple sections with same code) so they can be managed separately. The drawback to this is the code duplication, but it avoids the need for an app.

You can reduce code duplication by moving the actual HTML into a "snippet" and having all these duplicated sections simply include the same "snippet". You'd still have code duplication, but only the schema JSON in that case. https://www.shopify.com/partners/blog/88186566-tips-for-using-snippets-in-your-shopify-theme

Another workaround is to create "blocks" within your "section", then add a condition that a given block only appears on a specific page.

Unfortunately, neither of these are ideal: duplicating sections creates a code maintenance nightmare, while conditional blocks within a section is a cumbersome experience in the theme editor. Hopefully Shopify will give us "sections everywhere" some time soon.