# Section and block tags

Tags for section and theme block files: schema, javascript, stylesheet, sections, content_for, inline comments and doc.

These tags are used inside section files, theme block files and layouts. See [Theme structure](https://developer.versacommerce.de/articles/theme-structure) for how sections, section groups and blocks fit together.

## schema

Holds the JSON metadata of a section or theme block: its name, settings, blocks and presets. The content is not output. Translation keys starting with `t:` are resolved from the theme's schema locale files.

```liquid
{% schema %}
{
  "name": "Featured collection",
  "settings": [
    { "type": "text", "id": "heading", "label": "Heading", "default": "Our favorites" },
    { "type": "collection", "id": "collection", "label": "Collection" }
  ],
  "presets": [{ "name": "Featured collection" }]
}
{% endschema %}
```

## javascript

Registers JavaScript for a section or theme block, so that the script is output with the page.

```liquid
{% javascript %}
  document.querySelectorAll('.slider').forEach((el) => initSlider(el));
{% endjavascript %}
```

## stylesheet

Registers CSS for a section, so that the styles are output with the page.

```liquid
{% stylesheet %}
  .featured-collection { display: grid; gap: 1rem; }
{% endstylesheet %}
```

For CSS that uses setting values, use the [style](https://developer.versacommerce.de/articles/liquid-tags-theme-tags#style) tag.

## sections

Renders a section group, a JSON file in the **sections** folder that lists sections and their order. Layouts typically render a header group and a footer group around the page content.

```liquid
{% sections 'header-group' %}
{{ content_for_layout }}
{% sections 'footer-group' %}
```

## content_for

Renders theme blocks from the **blocks** folder inside a section or another block.

- `{% content_for 'blocks' %}` renders the blocks the merchant added in the theme editor, in their configured order.
- `{% content_for 'block', type: 'text', id: 'intro' %}` renders one static block of the given type with a fixed ID.

```liquid
<div class="hero">
  {% content_for 'block', type: 'heading', id: 'hero-heading' %}
  {% content_for 'blocks' %}
</div>
```

Inside a theme block, the [closest](https://developer.versacommerce.de/articles/liquid-objects-global-objects#closest) object gives access to the nearest product, collection, article, blog, page or metaobject of the rendering context.

## Inline comments

A tag that starts with `#` is a comment and is not output.

```liquid
{% # This line is not rendered %}
{% liquid
  # Comments also work inside liquid tags
  assign total = cart.item_count
%}
```

## doc

Documents a snippet or block: the parameters it expects and an example call. The content is not output.

```liquid
{% doc %}
  Renders a product card.

  @param {product} product - The product to show
  @param {boolean} [show_vendor] - Whether to show the vendor

  @example
  {% render 'product-card', product: product, show_vendor: true %}
{% enddoc %}
```
