简体   繁体   中英

How to use a Shopify Section across a Layout?

I have a section with content that can be edited from the Shopify Customizer. I use this section across multiple pages, but the content remains the same.

Is there a way to instead bind this section to a whole layout?

Because when you update the content, you have it re-enter it on every single page template that uses this section. I can have static HTML across all page templates that use a layout, but this isn't useful because the content needs to be editable from the Shopify Customizer.

You can have a section across a layout after all.

I was doing

layout/my-new-layout.liquid:
{% render 'section-component.liquid' %}

when I was supposed to be doing

layout/my-new-layout.liquid:
{% section 'section-component.liquid' %}

For reference

If you're trying to convert a template-only section to a layout-only section...

  1. Remove the section JSON data from the template: templates/page.your-template.json .
  2. Add a {% section 'your-section' %} in the layout (ie layout/my-new-layout.liquid ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM