Skip to content

content_for ​

Last updated View as Markdown

Use it in a section or a theme block to render theme blocks.

Blocks ​

liquid
{% content_for 'blocks' %}

The blocks that sellers added to the section or the block are rendered in the order of order. Disabled blocks are not rendered.

Static block ​

liquid
{% content_for 'block', type: 'price', id: 'price' %}

One static block is rendered. Sellers can edit its settings in the theme editor, but they cannot move or remove it.

Arguments ​

  • type: The theme block type, the file name in the blocks directory without the .liquid extension. Required.
  • id: The block ID. It must be unique inside the section or the block where you use the tag. Required.

You can pass more arguments. They are available as variables inside the block file. Use an argument whose name starts with closest. to set the matching closest object, for example closest.product: featured_product.

When type or id is missing, nothing is rendered.

Example ​

liquid
<div class="product-card">
  {% content_for 'block', type: '_product-image', id: 'image', closest.product: product %}
  {% content_for 'blocks' %}
</div>