Redirect home page to collection page - Dawn theme

Solved

Redirect home page to collection page - Dawn theme

mostafamoussa
Tourist
10 1 6

Hi all,

I'd like to re direct my homepage to the collections page. I cant seem to do this from navigation and url redirects. Essentially what i want is when you go to https://shop.prettylittlepeaches.com/ i want it redirected to https://shop.prettylittlepeaches.com/collections/all 

Is there any code i can put in the edit code to do this? Im using dawn theme. Thanks in advance. 

Accepted Solution (1)
mostafamoussa
Tourist
10 1 6

This is an accepted solution.

I edited the code and this seems to work. I added this to top of head tag

{% if template == 'index' %}
<script>
window.location.href = "COLLECTION_PAGE_URL _HERE";
</script>
{% endif %}

View solution in original post

Replies 13 (13)

Dbuglabpvtltd
Shopify Partner
705 75 116

Hi @mostafamoussa 
Please add this code before </head> tag.

{% if template == index %}
<script>
window.location.href = "COLLECTION_PAGE_URL _HERE";
</script>
{% endif %}
banned
mostafamoussa
Tourist
10 1 6

This did not seem to work, can you be more specific on placement? the collections page url is https://shop.prettylittlepeaches.com/collections/all 

Dbuglabpvtltd
Shopify Partner
705 75 116

can you please share your theme.liquid file code?

banned
amandalmeyer
Tourist
4 0 1

I'm trying to accomplish the same thing on my website. Redirect from my homepage (dawn theme) to another page on my website. 

mostafamoussa
Tourist
10 1 6

This is an accepted solution.

I edited the code and this seems to work. I added this to top of head tag

{% if template == 'index' %}
<script>
window.location.href = "COLLECTION_PAGE_URL _HERE";
</script>
{% endif %}

LegacyWand
Visitor
1 0 0

Works for me, however it breaks editing the original "Home Page" shopify becomes stuck  in infinite loop, however if you simply change away from that page it's works fine.

xoseabass
Visitor
2 0 1

works for me thanks a lot 😀

Aru1
Visitor
1 0 0

Hi, this solution does not work for me! I pasted the code under the head tag inside the theme.liquid file but the redirect does not work. Can someone help?

jtlyons24
Visitor
2 0 2

I know this is old but incase anyone faces this issue, make sure to include single quotes around the index, as below:

 

{% if template == 'index' %}

MattHK
Visitor
2 0 0

It goes ABOVE, the head tag, not under. 

(And don't forget to put the single quotes around index )

e.g. 

{% if template == 'index' %}
<script>
window.location.href = "your-domain-name-or-target-url";
</script>
{% endif %}

<head>

 

jtlyons24
Visitor
2 0 2

need to include single quotes around  index as so: {% if template == 'index' %}

notaaron1
Tourist
8 0 1

You're a Godsend

kwsm
Shopify Partner
1 0 0

Is there a way to do this do it is a 301 redirect? Google doesn't follow these types of redirects and this caused my home page to still get indexed and the page it redirects to get deindexed. 

 

More on this here