Solving the Mystery: Why Your Shopify Header Overlaps and Loses Color on Policy Pages

Hey there, fellow store owners! It's me, your friendly Shopify expert, dropping in with some insights from the community trenches. We've all been there: you make a cool customization on your homepage, like a transparent header that overlays a beautiful banner image, and suddenly, other pages on your site start acting up. Your header is overlapping text, or it's lost its background color entirely, looking all ghostly and unstyled. Sound familiar?

That's exactly what our community member, @luxepalmer, ran into recently. They were seeing their headers on policy pages (and eventually, all non-homepage pages) overlapping the main content, and the intended dark color scheme was nowhere to be found. Even AI tools like Sidekick weren't much help, sometimes introducing new problems!

The Root Cause: Global Styles and the Homepage Header Trick

The core of this issue often boils down to a common customization: making your header position: absolute and background: transparent specifically for your homepage. This creates that sleek, modern look where the header appears to float over your hero image.

The problem arises when these styles, meant only for the homepage, are applied globally. If your CSS rule for this transparent header doesn't explicitly tell Shopify to only apply it to the homepage, then every other page — your product pages, collection pages, blog posts, and yes, your policy pages — will inherit those same styles. This leads to the header floating over your content and losing its solid background.

Initially, @Moeed jumped in with a great first step, suggesting we wrap the problematic transparent header code in a conditional Liquid statement. This helps ensure it only applies to the homepage. Moeed's solution to fix the overlapping part of the issue was to add this code:

{% if template.name != "index" %}

{% endif %}

This snippet, placed in your theme.liquid file, tells the header to revert to its normal, position: relative behavior on any page that isn't the homepage (index). As @luxepalmer confirmed, this worked great for the overlapping issue!

The Deeper Dive: Background Color and Global CSS Overrides

However, even with the overlap fixed, @luxepalmer still couldn't get the header background color to appear correctly on non-homepage pages. This is where @Maximus3 stepped in with some crucial insights, really digging into the underlying CSS. It turned out there was a global CSS rule in base.css (or a similar stylesheet) that was forcing the header to be transparent everywhere:

/* Overlay header on top of image banner */
.header-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 20;
  background: transparent !important;
}

See that background: transparent !important;? That !important declaration is a powerful beast, overriding almost everything else. To properly address this, you need to make your CSS rules more specific, targeting the homepage with the transparent style and all other pages with a solid background.

Crucial Prerequisite: The template.name in Your Body Class

Before implementing the refined CSS, @Maximus3 highlighted a vital step that's often overlooked: ensuring your theme.liquid file includes the template name in the body class. This is what allows you to target specific page types with CSS, like .template-index (for the homepage) or body:not(.template-index) (for everything else).

Open your theme.liquid file and look for your body tag. It should look something like this:

If yours is missing template-{{ template.name }}, add it right before the closing quotation mark.

The Refined CSS Solution for Header Styling

Once your body class is correctly set up, you can replace that global .header-wrapper rule with this more targeted CSS, typically found in base.css or theme.css:

.template-index .header-wrapper {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    z-index: 20;
    background: transparent !important;
}
body:not(.template-index) .header-wrapper {
    position: relative;
    background: rgb(var(--color-background));
}

This code specifically applies the transparent, absolute positioning to the homepage header (.template-index .header-wrapper) and then, for all other pages (body:not(.template-index) .header-wrapper), it sets the position back to relative and applies your theme's default background color using rgb(var(--color-background)). This uses a CSS variable, pulling the background color from your theme settings, ensuring consistency.

What About Policy Pages Specifically?

While the above fix should sort out most of your header issues across the site, policy pages can sometimes be a bit unique. As @Maximus3 pointed out, Shopify's built-in URLs aren't always rendered by your theme templates in the exact same way as other pages, though they do inherit basic global styles.

If you wanted to change the background color of the policy page itself (not just the header) or add other specific styles, you could use these methods:

  1. In base.css:
    body[data-page-type="policy"] {
      background-color: #ffffff;
    }
    

    This targets the body tag specifically when the data-page-type attribute is set to policy.

  2. In theme.liquid (more targeted):
    {% if request.page_type == "policy" %}
    
    
    
    {% endif %}
    

    This injects a {% endif %}

And remember, after making any code changes, always hit 'Save' and check your store in an incognito window or clear your cache to see the updates. The community really shone through on this one, showing how a little bit of targeted CSS and understanding Liquid conditionals can solve tricky display issues. It's a great reminder that while Shopify themes are powerful, sometimes a bit of custom code is needed to get things just right, especially when you're aiming for that pixel-perfect design across all your store's pages!

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools