How to Hide Headers and Footers in Shopify: A Step-by-Step Guide

How to Hide Headers and Footers in Shopify: A Step-by-Step Guide

Table of Contents:

  1. Introduction
  2. Understanding the Concept of Hiding Headers and Footers on Shopify
  3. Step 1: Accessing the Code Editor
  4. Step 2: Locating the Header, Footer, and Announcement Bar Sections
  5. Step 3: Using Unless Statements to Hide Headers and Footers on Specific Pages
  6. Using Unless Statements to Hide Sections Within Sections
  7. Step 4: Targeting Specific Templates to Hide Headers and Footers
  8. Step 5: Targeting Specific Products to Hide Headers and Footers
  9. Using Product Titles to Hide Headers and Footers
  10. Additional Resources and Tips

Article:

How to Hide Headers and Footers on Specific Pages or Templates in Shopify

Introduction

If you're a Shopify store owner, you may have come across the need to hide certain elements like headers and footers on specific pages or templates. While the Shopify platform offers an easy way to show/hide sections, this method doesn't work for the header, footer, or even within sections. In this article, we'll explore a useful concept and skill to hide or conditionally output any element across your Shopify store. We'll go step by step to guide you through the process of hiding headers and footers on specific pages or templates on Shopify.

Understanding the Concept of Hiding Headers and Footers on Shopify

Before we dive into the code, it's important to understand the concept behind hiding headers and footers on Shopify. Unlike dynamic sections that you can easily drag and remove, headers, footers, and other non-dynamic sections are listed separately in the code. This means that to hide them, we need to edit the code directly. One way to achieve this is by using "unless" statements, which work as the opposite of "if" statements. By implementing "unless" statements, we can conditionally hide headers and footers on specific pages or templates.

Step 1: Accessing the Code Editor

To begin hiding headers and footers on specific pages or templates on Shopify, you need to access the code editor. In your Shopify admin, navigate to Themes and click on Actions. From the dropdown menu, select Edit code. This will open up the code editor where you can make the necessary changes to your theme's code.

Step 2: Locating the Header, Footer, and Announcement Bar Sections

In the code editor, locate the sections for the header, footer, and announcement bar. These sections are listed separately as they are not dynamic sections within the main content area. You may find them labeled as "section header," "section footer," and "section announcement bar." Identifying these sections is crucial as we'll be modifying their visibility using unless statements in the next steps.

Step 3: Using Unless Statements to Hide Headers and Footers on Specific Pages

Now that we've located the header, footer, and announcement bar sections, we can begin implementing unless statements to hide them on specific pages. In the code editor, open your "theme.liquid" file. Note that this method applies to Shopify 1.0 or vintage Shopify themes that don't have the ability to show/hide sections using the theme editor.

To hide the footer on all pages except the product page, we'll use an unless statement. Within the unless statement, we'll check if the template name is equal to "product." If it's not, we'll output the footer. Here's the code snippet:

{% unless template.name == 'product' %}
  <!-- Code to output the footer -->
{% endunless %}

Similarly, you can use unless statements to hide the announcement bar and header sections as well. Wrap each unless statement around the corresponding code for the sections. This way, the sections will only be visible on the product page, while hidden on other pages.

Using Unless Statements to Hide Sections Within Sections

Besides hiding entire sections like headers and footers, you may also need to hide specific elements within sections. If you want to hide elements that don't have a built-in option in the theme customizer, you can do that using code as well. This is particularly useful for older themes that don't support the show/hide sections feature.

To hide elements within sections, you can follow a similar approach as shown above. Locate the specific section in the code editor and apply unless statements to conditionally hide the desired elements. By using unless statements, you have the flexibility to hide any element within sections based on your requirements.

Step 4: Targeting Specific Templates to Hide Headers and Footers

In addition to hiding headers and footers on specific pages, you may want to target specific templates to hide these elements. If you've assigned custom templates to certain products or pages, you can use the template names to conditionally hide headers and footers. This method is particularly helpful if you're using Shopify 2.0 or have followed our templates video guide.

To target specific templates, you'll use unless statements with the template names. For example, if you have a template called "product.backpacks," you can hide the footer specifically on pages using this template. Here's the code snippet:

{% unless template.name == 'product.backpacks' %}
  <!-- Code to output the footer -->
{% endunless %}

This way, the footer will only appear on pages using the default product template, while hidden on pages using the "product.backpacks" template.

Step 5: Targeting Specific Products to Hide Headers and Footers

If you want even more granular control, you can hide headers and footers based on specific products. By targeting specific products, you can ensure certain items on your Shopify store don't show headers and footers. This method can be useful if you have unique products or want to create a custom experience for specific items.

To target specific products, you'll use properties like the product title or handle in your unless statement. For example, if you have a product called "Gift Product," you can hide the footer specifically on the product page for this item. Here's the code snippet:

{% unless product.title == 'Gift Product' %}
  <!-- Code to output the footer -->
{% endunless %}

This setup ensures that the footer is only hidden on the "Gift Product" page, while visible on all other product pages.

Additional Resources and Tips

If you find it challenging to remember all the template names, suffixes, or liquid syntax, Shopify provides a handy resource called the Shopify Liquid Cheat Sheet. It contains examples and information about the various liquid objects and syntax used in Shopify themes. You can refer to it whenever you need help with liquid code.

In conclusion, hiding headers and footers on specific pages or templates in Shopify requires a bit of coding knowledge. However, with the steps outlined in this article, you can confidently modify your theme's code to achieve the desired results. Remember to always make backups and test the changes in a development environment before applying them to your live store.

If you're interested in learning more about Shopify theme development or coding techniques, I recommend checking out the Shopify cheat sheet and other resources provided by Shopify. These resources can help you enhance your Shopify store and customize it to meet your unique requirements.

I am a shopify merchant, I am opening several shopify stores. I use ppspy to find Shopify stores and track competitor stores. PPSPY really helped me a lot, I also subscribe to PPSPY's service, I hope more people can like PPSPY! — Ecomvy

Join PPSPY to find the shopify store & products

To make it happen in 3 seconds.

Sign Up
App rating
4.9
Shopify Store
2M+
Trusted Customers
1000+
No complicated
No difficulty
Free trial