Reuse section with blocks on pages with different content

New Member
4 0 0

Hi, 

 

I've made a section with a schema with different blocks for my homepage. Which looks like this: (this snippet is not complete, but it gives a general idea of the code)

{% for block in section.blocks %}
  {% case block.type %}
    {% when 'image' %}
      {% include 'image' %}
    {% when 'video' %}
      {% include 'video' %}
    {% when 'text_image' %}
      {% include 'text-image' %}
    {% when 'collection_list' %}
      {% include 'collection-list' %}
  {% endcase %}
{% endfor %}
{% schema %}

{
  "name": "Contentblocks",
  "blocks": [
    {
      "type": "image",
      "name": "Image",
      "settings": [
        {
          "type": "image_picker",
          "id": "logo",
          "label": "Image"
        }
      ]
    }, {
      "type": "video",
      "name": "Video",
      "settings": [
        {
          "type": "url",
          "id": "video",
          "label": "Video URL"
        }
      ]
    }, {
      "type": "collection_list",
      "name": "Collection",
      "settings": [
        {
          "type": "collection",
          "id": "collection",
          "label": "Collection"
        }, {
          "type": "text",
          "id": "title_spacing",
          "label": "Title spacing"
        }, {
          "type": "text",
          "id": "title_narrow",
          "label": "Title narrow"
        }
      ]
    }
  ]
}

{% endschema %}

This section is included in my index.liquid, like this

{% section 'contentblocks' %}

Now, I actually want to use the exact same blocks on my about page, but with different content. So I've made an about page and made a template page.about.liquid and the same section is included. The problem is that the content stays the same between the two pages. If I edit something on the about page, it also changed on the homepage. 

 

How can I use the same blocks but with different content? I can duplicate the section (for example: contentblocks-about.liquid) and include that section on the about page. But if I then need to change something, I'll need to do it in different files, which is not a great solution either..

 

Thanks in advance,

Best wishes

0 Likes