![](https://forestbook-freelance.com/wp-content/uploads/2022/01/ScreenShot-48-1-1024x418.png)
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フォルダのファイル名を指定することで特定のページのみに表示させることができます!
![](https://forestbook-freelance.com/wp-content/uploads/2021/11/ブログ添付用-1024x271.png)
templateオブジェクトの使い方
templates/page.xxx.liquid
ファイルで使用した場合
template
: page.xxxtemplate.name
: pagetemplate.suffix
: xxx
コメント