# テンプレートによる分岐が反映されない

**URL:** <https://community.shopify.com/t/topic/422428>\
**Category:** Shopify テーマ\
**Tags:** html\
**Created:** [July 7, 2025, 2:24am UTC](https://community.shopify.com/t/topic/422428 "2025-07-07T02:24:25Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

ユーザーがShopifyテーマでブログ記事とその他のページで異なるヘッダーを読み込もうとした際、テンプレート分岐が正しく機能しない問題に直面しました。

**問題の詳細:**
- カスタマイズページから「デフォルトのブログ記事」に基づき新しいテンプレートを作成
- 新テンプレートを選択したブログ記事がブログ用ヘッダーを表示しない
- `theme.liquid`で`{% if template != 'blog' and template != 'article' %}`という分岐タグを使用していたが、記事として認識されていなかった

**解決方法:**
ユーザーが自己解決し、分岐の書き方を以下のように変更:
```
{% if request.page_type == 'blog' or request.page_type == 'article' %}
```

`template`変数ではなく`request.page_type`を使用することで正しく動作するようになりました。

<div class="post-metadata">

**Author:** ![tails0707](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@tails0707](https://community.shopify.com/u/tails0707)\
**Post date:** [July 7, 2025, 2:24am UTC](https://community.shopify.com/t/topic/422428/1 "2025-07-07T02:24:25Z")

</div>

まず、初めにブログ・ブログ記事とそれ以外のページで読み込むヘッダーを分けています。

記事によってテンプレを変えたいため、カスタマイズページから「デフォルトのブログ記事」に基づきテンプレートを作成しました。

しかし、この新しいテンプレートを選択したブログ記事はブログ用のヘッダーになりません。

theme.liquidには以下のように分岐タグがあるのですが、他にも設定が必要なのでしょうか？

articleとして認識していないようです。

ご教授いただければ幸いです。

```auto
{% if template != 'blog' and template != 'article' %}
{% section 'header' %}
{% else %}
{% section 'blog-header' %}
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![tails0707](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@tails0707](https://community.shopify.com/u/tails0707)\
**Post date:** [July 7, 2025, 6:59am UTC](https://community.shopify.com/t/topic/422428/2 "2025-07-07T06:59:25Z")

</div>

自己解決しました。

分岐の書き方がまずかったようです。

```markup
{% if request.page_type == 'blog' or request.page_type == 'article' %}

```
