How do I change the background color of just my product pages?

Topic summary

A user wanted to change the background color exclusively on product pages to eliminate visible “stripes” between section blocks caused by the theme’s default background color showing through.

Initial Solution:

  • Add custom CSS to theme.liquid file (above </body> tag)
  • Set body { background-color: #f5f5f5; }
  • This successfully changed the background but affected all pages site-wide

Final Solution:

  • Wrap the CSS in a Liquid conditional: {% if template contains 'product' %}
  • This targets only product pages while leaving other pages unchanged

Status: Resolved. The user confirmed the conditional approach worked as intended.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

I am trying to change the color of the background on just my product page. I can change the color of each individual section block but I don’t like that the theme background color comes through between each block. I want to make it the same color so that you don’t see the stripes.

1 Like

Hey @yakobi93

Welcome to Shopify Community! Can you share your Store URL so I can have a look on it? Also, if you have password enabled then please share the password as well. Your cooperation would be greatly appreciated.

Best Regards,
Moeed

1 Like

donutz

Apologies, I didn’t supply the URL: donuthome.co
and the password is donutz

1 Like

Hey @yakobi93

Follow these Steps:

  1. Go to Online Store

  2. Edit Code

  3. Find theme.liquid file

  4. Add the following code in the bottom of the file above tag


RESULT:

If I managed to help you then, don’t forget to Like it and Mark it as Solution!

Best Regards,
Moeed

That did work however, it looks like it changed it across all pages. It there a way to make it so this only affects the product page?

1 Like

Hey @yakobi93

Try this updated code with the same steps mentioned above.

{% if template contains 'product' %}

{% endif %}

If I managed to help you then, don’t forget to Like it and Mark it as Solution!

Best Regards,
Moeed

1 Like

This worked, thank you!

1 Like

Thank you for your reply. I’m glad to hear that the solution worked well for you. If you require any more help, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated.