Vikrant
Vikrant

Reputation: 1

How to find current url in any Shopify Liquid file (page.url and request.url not working)

We are injecting a modal in our site, which is being build using Shopify liquid templates. And we want to change the css of that modal according to the url change. I have tried window global object but it is not working as it involve server side rendering. also page.url and request.url global liquid object didn't worked for me.

Liquid file structure

Liquid file structure

I am new to Shopify liquid template, Please help me here. Thanks and regards

Upvotes: 0

Views: 1507

Answers (1)

John Shot
John Shot

Reputation: 306

Try with a case statement and change your CSS based on the page handle:

{% case page.handle %}
   {% when 'page-handle-one' %}
      do something...
   {% when 'page-handle-two' %}
      do something else...
   {% else %}
{% endcase %}

Upvotes: 0

Related Questions