How to load a different theme.liquid file based on url?

Topic summary

Goal: serve different layouts/content per domain or subdomain within one Shopify theme without creating a second store.

Key attempts and findings:

  • Conditional layouts via Liquid: using request.host to switch {% layout %} worked, but content_for_index still renders the same homepage sections, limiting domain-specific content. content_for_layout/content_for_index cannot be conditionally altered. She notes carts appear separate between domains.
  • Alternative approach implemented: removed subdomains and connected two domains to the same store with redirect disabled. In theme.liquid, added a JavaScript redirect only for domain2.com at the root path to send users to domain2.com/pages/pagename.

Implementation details:

  • Created page template page.pagename.liquid with {% layout none %}, copied necessary HTML structure from theme.liquid, and included a custom section (newpage-index.liquid) with schema to enable section-based customization on that page.
  • Caveat: direct access to domain1.com/pages/pagename shows the same content as domain2’s page; considering another redirect to mitigate.

Status: workable client-side redirect solution in place; still open questions about Shopify-controlled templates (password.liquid, gift_card.liquid) and finer control over content_for_index. Code snippets are central to the solution.

Summarized with AI on January 2. AI used: gpt-5.

Update on my progress:

I’ve done away with the subdomains for now, connected domains domain1.com and domain2.com, both domains connected to shopify, with shopify’s option for redirect disabled.

In the theme.liquid file, at the very beginning of the tag I included:

{% if request.host == ‘domain2.com’ and request.path == ‘/’ %}

{% else %}
{% endif %}

-Thanks to Steven_Amrhein’s answer here.

So I’ve created a page template, called page.pagename.liquid, which sets {% layout none %} and have copy/pasted relevant info from theme.liquid (such as html structure) a new section called newpage-index.liquid which is called from page.pagename.liquid and includes schema to create adjustable sections on the page pagename.

When the user types in domain2.com, they are redirected to the page “pagename”.

When the user types in domain1.com, they are directed the home page of domain1.com.

Unfortunately, if the user types in domain1.com/pages/pagename, they will be directed to the same content as domain2.com/pages/pagename. I’m thinking of setting another redirect so if the user does type it in, they will be directed back the home page at domain1.com

How likely is it that a user will type in the exact address: domain1.com/pages/pagename, when there is no direct link to suggest that is a page? I’ve done this a few times for sites, when trying to find out the root page- only going further up, but never guessing pages names…

1 Like