
theme.liquidに{%- if template == ‘テンプレートファイル名’ -%} を使う
コードを挿入する場所
layout/theme.liquid
の headタグの閉じタグ(</head>)の直前に挿入します
トップページのみ表示させたい場合
layout/theme.liquid
...省略
{%- if template == 'index' -%}
表示させたい要素
{%- endif -%}
</head>
「ページ」で作成したページ(page.xxx.liquid)のみ表示する場合
...省略
{%- if template == 'page.xxx' -%}
表示させたい要素
{%- endif -%}
</head>
templatesフォルダのファイル名を指定することで特定のページのみに表示させることができます!

templateオブジェクトの使い方
templates/page.xxx.liquid
ファイルで使用した場合
template
: page.xxxtemplate.name
: pagetemplate.suffix
: xxx
コメント