Ecommerce layout on 2 domain site

My client has 2 domains on his hosting and I thought I could just duplicate pages to show the 2 different sites. I set up a different template for each domain but I’m running into problems when I click through using dynamic data (like ecommerce and news). Basically I have 1 page but I want to be able to deliver the page on a template based on the URL in use.
Does anyone know if this is possible?

Hi @doodlefish
I would just use one template but conditionally change its contents (head/footer) based on the URL.

You can achieve this with the Liquid request object, using request.request_url.origin:
https://docs.treepl.co/liquid/request-object

eg, in your template:

<!DOCTYPE html>
<html>
    <head>
    {% if request.request_url.origin == 'https://domain1.com' %}
      <!-- Domain 1 template head content -->
    {% else %}
      <!-- Default domain head content -->
    {% endif %}

    <!-- Shared template head content could be added here to avoid repeating yourself -->

    </head>
    <body>

    {{pageContent}}

    {% if request.request_url.origin == 'https://domain1.com' %}
      <!-- Domain 1 template footer content -->
    {% else %}
      <!-- Default domain footer content -->
    {% endif %}

    <!-- Shared template footer content could be added here to avoid repeating yourself -->

    </body>
</html>

Thanks Adam - you are a legend as always :laughing:

I’ll give that a try

hi Adam - I tried setting this up - logically I think it should work, but it doesn’t.
https://vehicleinspectionstas.com.au/inspection-contact. Its still using the default domain settings.
This is what I’ve added in

        {% if request.request_url.origin == 'https://vehicleinspectionstas.com.au/' %}
            <!-- Domain 1 template head content -->
            {% component type: "snippet", alias: "vi-header-twin-nav" %}
        {% else %}
            <!-- Default domain head content -->
            {% component type: "snippet", alias: "header-twin-nav" %} 
        {% endif %}
This should be delivering the logo and menu on this page

The condition has to match exactly and the origin object doesn’t include the trailing forward slash (/) on the end of the domain. So just remove that from your IF statement so it’s just:

 {% if request.request_url.origin == 'https://vehicleinspectionstas.com.au' %}
...

cool. thanks. That worked a treat!