Change the index template if the user is logged in Shopify

Shopify, theme Expanse.

I have two index templates - index.json and index.logged.json. And I want the site user to be redirected to index.logged.json if that user is logged in. I know how to verify the user:

{% if customer %}
   ...
{%- endif -%}

But how do I display index.logged.json if that user is logged in? Where should I write this condition?

Please help.

Hi @max_max_max

Access two different index templates you just need to add below script in theme.liquid file.


You can also add/edit/remove section in new index template from CMS.

I hope that this will help you to fulfil your requirements.

Happy coding!!

1 Like

I did it differently, but my solution is similar to yours!

Thanks you! :slightly_smiling_face: