# 登録されているコレクション名とタグを表示したい

**URL:** <https://community.shopify.com/t/topic/9904>\
**Category:** 技術的なQ＆A\
**Created:** [March 11, 2020, 1:36am UTC](https://community.shopify.com/t/topic/9904 "2020-03-11T01:36:23Z")\
**Posts on this page:** 3\
**Page:** 1

## AI-generated summary

Shopifyのフッターに、登録済みコレクション名と各コレクションのタグ一覧をLiquidで表示したい、という質問。目的は商品を「大カテゴリ／中カテゴリ」のように見せることで、コレクション運用が適切かもあわせて確認したいという内容だった。画像は、管理画面でコレクション条件にタグを設定している状況の補足として使われている。

その後、質問者が自己解決し、Liquidコードを共有した。内容は以下の通り。
- `for collection in collections` で全コレクションをループ
- `collection.title` と `collection.url` でコレクション名とリンクを表示
- `collection.all_tags` でそのコレクションに紐づくタグ一覧を取得
- `link_to_tag` を使って各タグへのリンクURLを生成

最終的に、コレクション名とタグの表示方法については解決済み。ただし、「コレクションの使い方として適切か」という設計面への追加回答はなく、その点は明確な結論が出ていない。

<div class="post-metadata">

**Author:** ![yohaku-shimizu](https://avatars.discourse-cdn.com/v4/letter/y/d07c76/32.png) [@yohaku-shimizu](https://community.shopify.com/u/yohaku-shimizu)\
**Post date:** [March 11, 2020, 1:36am UTC](https://community.shopify.com/t/topic/9904/1 "2020-03-11T01:36:23Z")

</div>

初歩的な質問ですみません、最近初めてliquidを触り始めた者です。

フッタースペースにショップで登録されているコレクション名と、そのコレクションの条件に指定されているタグ名を表示したいです。

 ![situmon01.jpg](https://canada1.discourse-cdn.com/shopifyforum/original/3X/b/c/bc69f0c069e0d77fc0675da358ca85e5007c4bd8.jpeg)  
イメージは商品を大カテゴリ、中カテゴリのように管理したいのですが、shopifyにはそういったものが見当たらなかったのでコレクションを使用しました。

表示方法と、もしコレクションの使い方が間違っていたらご教示いただけると幸いです。

宜しくお願い致します。

---

<div class="post-metadata">

**Author:** ![yohaku-shimizu](https://avatars.discourse-cdn.com/v4/letter/y/d07c76/32.png) [@yohaku-shimizu](https://community.shopify.com/u/yohaku-shimizu)\
**Post date:** [March 13, 2020, 6:47am UTC](https://community.shopify.com/t/topic/9904/2 "2020-03-13T06:47:30Z")

</div>

```auto
{% for collection in collections %}
          <p><a href="{{ collection.url }}">{{ collection.title }}</a></p>
          <ul>
            {%- for tag in collection.all_tags -%}
              {%- assign new_url = tag | link_to_tag: tag | split: 'href="' | last | split: '"' | first -%}
              <li><a href="{{ new_url }}"{% if current_tags contains tag %} selected="selected"{% endif %}>{{ tag }}</a></li>
            {%- endfor -%}
          </ul>
          {% 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:** [March 23, 2020, 7:27am UTC](https://community.shopify.com/t/topic/9904/3 "2020-03-23T07:27:23Z")

</div>

ありがとうございます！
