How to remove local language portion from URL path?

How can i remove the local language portion from URL path,
{{ request.path }} render all the URL including the "/ar/"page/example,
how can i remove the “/ar/” part from the URL path.

Thanks in Advance

{%- if shop.locale == ‘ar’ -%}

Englsih

{%- else -%}

arabic

{%- endif -%}

Hi @AdamAnas

You can do it like this

{{ request.path | remove: request.locale.root_url }}

Kani_3-1681006762628.png

If you want to learn more, you can refer to this document.

https://shopify.dev/docs/api/liquid/objects/request

1 Like

When the customer is on the homepage and tries to back to English from Arabic, it’s not working. The issue on when the user is on the homepage.

Updated code as follows

{%- if shop.locale == ‘ar’ -%}

Englsih
{%- else -%}
arabic
{%- endif -%}

Hi @AdamAnas

You can certainly concatenate the URL yourself.


Also, please pay attention to some information mentioned in the documentation.