Hi there, I am using the Sense theme and I have recently applied some CSS to make my header look like this:
Here is the code for it:
{% endif %}
This is good, but now my product page looks like this:
It’s too bunched up, I would like the CSS I have applied to only be applied to the home page, and not all pages. Thanks for any help
You should use
{% if template.name == 'index' %}
instead of
{%if template contains 'index'%}
1 Like
The product page hasnt changed unfortunately
That means you are using different code for product page, can you share the link to your store?
It’s fine for me @Vitalum ,
Can you clear cache or try another browser?
I had the wrong version published, I am so sorry! Please check the updated version.
No wonder, you pasted it in the wrong file, you can’t write liquid code on files ending with .css. You can only write it on files that end with .liquid. Also you can’t put tags in css files. You add them in HTML files.
Take this same code and follow these instructions. Please delete the code from base.css
Go to your theme’s “Edit Code” Option, then in the search bar type “theme.liquid”
Below the tag “” tag paste the following. Screenshot attached for reference.
{% if template.name == 'index' %}
{%endif%}
Screenshot is for reference only, the correct code to paste is the one shown above.
1 Like