Shopify themes, liquid, logos, and UX
Hi!
I'd like to change the menu nav colour on some pages to beige and others to green. I've tried this snipped in my theme.liquid file but no dice. My default menu nav colour in my theme editor is beige, but something is still making the ones I want to be beige, green. I've tried the code snippets below with no luck:
<style>
{% if template.name == 'page.about' or
template.name == 'page.privacy' or
template.name == 'page.returns-refunds' or
template.name == 'page.shipping' or
template.name == 'page.legal' or
template.name == 'page.faq' or
template.name == 'page.default' or
template.name == 'page.contact' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>
AND:
<style>
{% if template.name == 'index' or
template.name == 'page.learning-about-lab-grown' or
template.name == 'page.all-about-diamonds' or
template.name == 'page.our-process' or
template.name == 'page.lookbook' or
template.name == 'page.how-to-find-your-ring-size' %}
.navtext {
color: #f5f5dc !important; /* Beige color for specified pages */
}
{% endif %}
</style>
My website is unadiamond.com
Solved! Go to the solution
This is an accepted solution.
Hi @unadiamond,
Please change code:
template.name
=>
template
For example:
<style>
{% if template == 'page.about' or
template == 'page.privacy' or
template == 'page.returns-refunds' or
template == 'page.shipping' or
template == 'page.legal' or
template == 'page.faq' or
template == 'page.default' or
template == 'page.contact' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>
Hello @unadiamond ,
Important is already used in the cs that's why your css is not working.
You need to use parent element with the class to override it.
like
.navlink .navtext{
// You css will be here
color: #f5f5dc !important;
}
Please give it a try and let me know.
If problem solved don't forget to Like it and Mark it as Solution!
And if you need help with customization/code part you can contact me for services
You can find the email in the signature below.
Thanks
Hi @unadiamond
This is Richard from PageFly - Shopify Page Builder App
If your current code is targeting the Template-Name and apply the CSS based on Condition, i suggest you can do another is handle of page.
So for example your page is = /pages/learning-about-lab-grown' => so the code will be
{% if handle contains 'learning-about-lab-grown' %}
This will target it by URL and you will have more easier way to control it
Hope this can help you solve the issue
Best regards,
Richard | PageFly
Please let me know if it works by giving it a Like or marking it as a solution!
➜ Optimize your Shopify store with PageFly Page Builder (Free plan available)
All features are available from Free plan. Live Chat Support is available 24/7.
This is an accepted solution.
Hi @unadiamond,
Please change code:
template.name
=>
template
For example:
<style>
{% if template == 'page.about' or
template == 'page.privacy' or
template == 'page.returns-refunds' or
template == 'page.shipping' or
template == 'page.legal' or
template == 'page.faq' or
template == 'page.default' or
template == 'page.contact' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>
you're the best, thank you!!!
Hi @unadiamond,
You're welcome and happy to help
sorry quick follow up - how do i make the blog and product pages green too? i've followed the logic of your code and applied them to page.product + page.blog but they remain beige
sorry quick follow up - how do i make the blog and product pages green too? i've followed the logic of your code and applied them to page.product + page.blog but they remain beige
Hi @unadiamond,
Please add code:
<style>
{% if template == 'page.about' or
template == 'page.privacy' or
template == 'page.returns-refunds' or
template == 'page.shipping' or
template == 'page.legal' or
template == 'page.faq' or
template == 'page.default' or
template == 'page.contact' or
template == 'product' or
template == 'blog' %}
.navtext {
color: #004335 !important; /* Green color for specified pages */
}
{% else %}
.navtext {
color: #f5f5dc !important; /* Beige color for all other pages */
}
{% endif %}
</style>
Hi @unadiamond
You can try to use code example like this below and check
{% if template == 'index' or
page.handle == 'about' or ... }%
<style>
</style>
{% else %}
<style>
</style>
{% endif %}
- Helpful? Like & Accept solution! - Support me? Buy me a coffee
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025