Liquid, JavaScript, themes, sales channels
Hello,
I was curious if the capabilities of sections allow for a section to be added to two different page templates but have different data populating it? Currently, I'm seeing the same data I entered in the section for page 1 on page 2. Is there some type of workaround or something that I might have missed?
Page 1:
{% section 'banner' %}
Headline field data entered: Hello Page 1
Page 2:
{% section 'banner' %}
Headline field data entered: Hello Page 2
I hope the only solution isn't to create multiple sections like banner-homepage.liquid, and banner-interior-page.liquid.
Solved! Go to the solution
This is an accepted solution.
There's not a specific number limit to how many sections that I know of, but there is a file size limit to the settings_data.json file, which is where the content for the sections is stored. This also demonstrates why sections are not scalable and available to use uniquely on every page.
Unfortunately, it's not possible. If you want to use theme sections, you would have to create one for each page you want to use it on. This isn't really a scalable solution, so you might want to consider building the banner with metafields instead.
It's worth noting that Shopify is actively revamping how this works, dubbed "Sections Everywhere", but there is no ETA for when it will be rolled out.
Hi @gina-gregory,
Thank you for your quick response. You're right this isn't ideal and makes for a bloated codebase. I can't wait for that feature to be rolled out.
You make mention of building the "banner" using metafields. Can you elaborate a little more on that? We do have the ACF plugin installed. This might be a dumb question but is there a limit to the number of sections that can be created and added to the project?
You could create metafields that contain the page-specific settings you need, and then use that to build your banner.
<section class="banner" style="background-image: url({{ page.metafields.banner.image }});">
<h2 style="color: {{ page.metafields.banner.title_color }}">{{ page.metafields.banner.title }}</h2>
</section>
This is an accepted solution.
There's not a specific number limit to how many sections that I know of, but there is a file size limit to the settings_data.json file, which is where the content for the sections is stored. This also demonstrates why sections are not scalable and available to use uniquely on every page.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024