Shopify themes, liquid, logos, and UX
Hi everyone,
I’m managing a single Shopify store that sells two different product lines—leather bags and vegan bags. I want to implement a toggle switch in the header that allows customers to switch between these two lines.
I’d appreciate any guidance, examples, or relevant Shopify documentation!
Thanks in advance! 🚀
Hi @Dev_Lehavi
I am from Mageplaza - Shopify solution expert.
This is a great setup and a common use case for multi-brand stores using subdomains on Shopify. You want a header toggle that can switch between mystore.com (Leather) and vegan.mystore.com (Vegan), with branding and navigation updating accordingly.
1. What’s the best way to implement the toggle? JavaScript, Liquid, or an app?
Best approach: A combination of Liquid for rendering the toggle, and JavaScript for handling redirection and persistence (cookies or localStorage).
Here’s a typical workflow:
You don’t need an app unless you want advanced segmentation or user accounts syncing across domains.
2. How can I detect the current subdomain and adjust the navigation accordingly?
Use Liquid and Javascript:
Option A – Using request.host in Liquid:
{% assign is_vegan = request.host contains 'vegan' %}
{% if is_vegan %}
<!-- Vegan brand navigation -->
{% else %}
<!-- Leather brand navigation -->
{% endif %}
This will dynamically change content, menus, logos, colors, etc., based on the subdomain.
Option B – JavaScript fallback:
const currentDomain = window.location.hostname;
if (currentDomain.includes("vegan")) {
// Adjust DOM or branding via JS
}
3. How to persist customer selection (e.g., stay on Vegan if they come back)?
You can use localStorage or cookies.
Example using localStorage:
// When user clicks toggle:
document.querySelector('#brand-toggle').addEventListener('click', function () {
const current = window.location.hostname;
if (current.includes("vegan")) {
localStorage.setItem("preferred_brand", "leather");
window.location.href = "https://mystore.com";
} else {
localStorage.setItem("preferred_brand", "vegan");
window.location.href = "https://vegan.mystore.com";
}
});
Optional Auto-Redirect on First Visit:
document.addEventListener("DOMContentLoaded", function () {
const preferred = localStorage.getItem("preferred_brand");
const host = window.location.hostname;
if (preferred === "vegan" && !host.includes("vegan")) {
window.location.href = "https://vegan.mystore.com";
} else if (preferred === "leather" && host.includes("vegan")) {
window.location.href = "https://mystore.com";
}
});
You should avoid forcing redirect too aggressively, or it may annoy returning users.
4. Are there any Shopify apps that support this kind of multi-brand toggle?
There are no specific apps designed for toggling subdomain branding with this exact behavior. However, here are options that might help:
Useful Apps:
But your use case is fairly custom — building the toggle manually gives you more control.
Please let me know if it works as expected!
Best regards!
Mageplaza | Top-Rated Shopify Agency | Trusted by 230,000+ worldwide merchants
If our suggestion works for you, please give it a Like or mark it as a Solution!
Should you have any questions or concerns, feel free to contact us via consultant@mageplaza.com
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025