はじめまして。
現在テーマDawnでECサイトを作成しています。
デザイン面からTOPページのヘッダーとフッターのみ非表示にしたいのですが上手くいきません。
方法が御座いましたらご教示いただけますと幸いです。
解決済! ベストソリューションを見る。
成功
theme.liquidを開き、{% section 'header' %}と{% section 'footer' %}の部分を以下のようにしてください。
{% if template != 'index' %}
{% section 'header' %}
{% endif %}
{% if template != 'index' %}
{% section 'footer' %}
{% endif %}
トップページは「index.json」テンプレートを使用するので、テンプレートがindex以外は{% section %}を出力するという分岐をそれぞれに適用させます。
また、{% unless == 'index' %}〜{ % endunless %}を使っても同様の処理が可能です。
成功
theme.liquidを開き、{% section 'header' %}と{% section 'footer' %}の部分を以下のようにしてください。
{% if template != 'index' %}
{% section 'header' %}
{% endif %}
{% if template != 'index' %}
{% section 'footer' %}
{% endif %}
トップページは「index.json」テンプレートを使用するので、テンプレートがindex以外は{% section %}を出力するという分岐をそれぞれに適用させます。
また、{% unless == 'index' %}〜{ % endunless %}を使っても同様の処理が可能です。
トップページではなく、特定のページのみ、ヘッダー・フッターを非表示にするにはどうすれば良いでしょうか?
「特定のページ」というのは、「ドメイン/pages/ハンドル」といったPagesで作成したページのことでしょうか?
以下のような分岐で非表示にできると思います。
{% if page.handle != 'ハンドル名' %}
{% section 'header' %}
{% endif %}
{% if page.handle != 'ハンドル名' %}
{% section 'footer' %}
{% endif %}
もしくは
{% unless page.handle == 'ハンドル名' %}
{% section 'header' %}
{% endunless %}
{% unless page.handle == 'ハンドル名' %}
{% section 'footer' %}
{% endunless %}