Membuat Section Kustom & Blok {% schema %}

Cara membangun file section di sections/*.liquid dan mendefinisikan kontrol visual di Customizer menggunakan blok {% schema %}.

Anatomi File Section

Setiap file di dalam sections/ terdiri dari dua bagian: markup tampilan di bagian atas yang membaca section.settings, dan blok {% schema %} ... {% endschema %} di bagian bawah yang menjelaskan kontrol apa saja yang muncul di Customizer.

LIQUID
<section class="promo-band" style="background-color: {{ section.settings.bg_color }};">
  <div class="container">
    {% if section.settings.eyebrow != blank %}
      <span class="eyebrow">{{ section.settings.eyebrow }}</span>
    {% endif %}
    <h2>{{ section.settings.heading }}</h2>
    {% if section.settings.image != blank %}
      <img src="{{ section.settings.image | image_url: 'large' }}" alt="{{ section.settings.heading | escape }}" loading="lazy">
    {% endif %}
    {% if section.settings.cta_label != blank %}
      <a class="btn" href="{{ section.settings.cta_link | default: routes.collections_url }}">
        {{ section.settings.cta_label }}
      </a>
    {% endif %}
  </div>
</section>

{% schema %}
{
  "name": "Promo Band",
  "settings": [
    {
      "type": "text",
      "id": "eyebrow",
      "label": "Label Kecil",
      "localized": true,
      "default": "Penawaran Terbatas"
    },
    {
      "type": "text",
      "id": "heading",
      "label": "Judul Utama",
      "localized": true,
      "default": "Diskon Akhir Pekan hingga 30%"
    },
    {
      "type": "image",
      "id": "image",
      "label": "Gambar Banner"
    },
    {
      "type": "color",
      "id": "bg_color",
      "label": "Warna Latar",
      "default": "#f4f7fb"
    },
    {
      "type": "text",
      "id": "cta_label",
      "label": "Teks Tombol",
      "localized": true,
      "default": "Lihat Promo"
    },
    {
      "type": "url",
      "id": "cta_link",
      "label": "Tautan Tombol",
      "default": "/kategori"
    }
  ],
  "presets": [
    {
      "name": "Promo Band"
    }
  ]
}
{% endschema %}

Tipe Input yang Didukung Customizer

Tipe Tampilan di Customizer
text / textarea / richtext Kolom teks satu baris, paragraf panjang, atau editor teks terformat.
image Pemilih gambar terhubung langsung ke Media Library toko.
color Pemilih warna interaktif dengan sinkronisasi kode hex.
range Slider angka dengan batas min, max, step, dan satuan (misalnya px atau detik).
checkbox / select Sakelar aktif/nonaktif atau pilihan dropdown.
url / link_list Pemilih tautan halaman atau pemilih menu dari Multi-Menu Builder.
product / category / page Pemilih produk, kategori, atau halaman milik toko secara langsung.