Exclude content from specific pages in Shopify

August 15, 2023

Step 1

Select “Online Store” from the main menu on the left.

Step 2

Select “Themes” in the “Online Store” sub menu.

Step 3

Select the button with 3 dots next to “Customize”, then select “Edit code” in the sub menu.

Step 4

Search for the “theme.liquid” file and select it.

Step 5

Locate the content you want to exclude.

For this example, we'll be excluding the theme's header.

{% section 'header' %}

Step 6

Use an 'unless' tag to specify which page you'd like to exclude.

In the first example, we exclude the cart page by checking 'template.name' for the word 'cart'. You can find template types in the shopify.dev documentation.


{% unless template.name == 'cart' %}
  {% section 'header' %}
{% endunless %}
                

If you're trying to exclude a specific page that isn't a 'template', like an a custom About page, you can check 'page.handle' for the page's URL slug. You can also check the 'page' object for a page's title, ID, and more (see shopify.dev).


<!-- Exclude specific page -->

{% unless page.handle == 'about' %}
  {% section 'header' %}
{% endunless %}

<!-- Exclude pages that contain a common word -->

{% unless page.handle contains 'blog' %}
  {% section 'header' %}
{% endunless %}