# 商品ページで商品タグに応じて（割引！など）文字を出す方法

**URL:** <https://community.shopify.com/t/topic/23861>\
**Category:** 技術的なQ＆A\
**Created:** [October 29, 2020, 5:47am UTC](https://community.shopify.com/t/topic/23861 "2020-10-29T05:47:34Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

商品ページで商品タグ（例: 「割引！」）を表示したいが、`{% for tag in product.tags %}{{ tag }}{% endfor %}` をどのテンプレートに書けばよいか、という質問。`product.tags` は商品のタグ一覧を順に出力する Liquid の記述。 

回答では、挿入箇所は使用中の Shopify テーマ構成によって異なると説明されている。商品ページなら、主に `product.liquid`、またはそこから読み込まれる `product-template.liquid` が候補。さらに、`theme.liquid` に `alert("{{template}}");` のような JavaScript を一時的に入れると、現在どのテンプレートが呼ばれているか確認できる、という具体的な確認方法も示された。 

結論として、表示コード自体は判明しているが、実際の設置先はテーマ依存で、最終的な適用先の特定は利用者側で確認が必要な状態。

<div class="post-metadata">

**Author:** ![THTHTHTH](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@THTHTHTH](https://community.shopify.com/u/THTHTHTH)\
**Post date:** [October 29, 2020, 5:47am UTC](https://community.shopify.com/t/topic/23861/1 "2020-10-29T05:47:34Z")

</div>

お世話になってます。初学者です。

商品にタグをつけました。

その商品タグの文字を表示させる方法を教えてください。

{% for tag in product.tags %}  
{{ tag }}  
{% endfor %}

上記のコードが必要だということはわかったのですが、どこに記述したらいいかわかりません。

どうぞよろしくお願いいたします。

---

<div class="post-metadata">

**Author:** ![junichiokamura](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/junichiokamura/32/299737_2.png) [@junichiokamura](https://community.shopify.com/u/junichiokamura)\
**Post date:** [November 10, 2020, 1:53pm UTC](https://community.shopify.com/t/topic/23861/2 "2020-11-10T13:53:24Z")

</div>

お使いのテーマによって挿入箇所は異なりますが、基本構成は以下となります。

[https://shopify.dev/docs/themes/theme-templates](https://shopify.dev/docs/themes/theme-templates)

商品ページに出す際は、

product-liquid か、そこから呼ばれている、product-template.liquid かと思います。

theme.liquid に alert(“{{template}}”); といったJavaScriptを書くと今どのファイルが呼ばれているかわかります。
