Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Changing default landing page to product page sense theme

Solved

Changing default landing page to product page sense theme

samm7560
Tourist
3 0 1

Hi everyone,

 

On my product page I have full details and an app integrated onto it with trust badges which I cannot display on my home page. I would like to change the default "home" page to my product page. I previously tried this line of code however it redirected to collection page and I cannot find the correct solution: 

{%- if template contains 'index' -%}
<script>
window.location.href = '/products';
</script>
{%- endif -%}

 

Id then just like to completely remove the home page in its entirety as I will have no need for it as product page will be the new homepage.

 

Thanks!

Accepted Solution (1)

amanbatra
Shopify Partner
104 14 17

This is an accepted solution.

Hello @samm7560 

 

You are using the code you just set it to the products you need to pass the handle of the product too which you can get from the product page url

{%- if template contains 'index' -%}
<script>
window.location.href = '/products/handle-of-product';
</script>
{%- endif -%}

Is the solution works for you ? please Like and Accept Solution.
Need more help with theme customization and store development ?
WA: +917508271396, Email: amanbatra.developer@gmail.com, Skype: amanbatra.developer

View solution in original post

Replies 6 (6)

amanbatra
Shopify Partner
104 14 17

This is an accepted solution.

Hello @samm7560 

 

You are using the code you just set it to the products you need to pass the handle of the product too which you can get from the product page url

{%- if template contains 'index' -%}
<script>
window.location.href = '/products/handle-of-product';
</script>
{%- endif -%}

Is the solution works for you ? please Like and Accept Solution.
Need more help with theme customization and store development ?
WA: +917508271396, Email: amanbatra.developer@gmail.com, Skype: amanbatra.developer
samm7560
Tourist
3 0 1

Thank you very much! I did try this last night and got a 404 page instead but this has now worked!

Sam141414
Visitor
1 0 0

Hi, 


Where did you put this code in order to change it. 

 

AAA19
Visitor
1 0 0

go to custom liquid and input that code

 

Cal35
Tourist
4 0 3

Where do you input it in the custom liquid? I add a section and paste it but it still doesn't change anything

Cal35
Tourist
4 0 3

{%- if template contains 'index' -%}
<script>
window.location.href = '/products/(insert whatever is in the URL)';
</script>
{%- endif -%}

 

Click on the 3 dots next to customize theme and past this in the theme.liquid section near the top of the categories on the left. when you paste it make sure to paste it just above the head section. if you have any trouble with this message me back or paste what i just said in chatgpt and ask it to explain the steps better!