Custom Canonical URL

New Member
3 0 0

I have this page

https://blissfulsleep.com/pages/mattress-store-los-angeles-ca

I would like the canonical URL to point to the homepage. The homepage pulls this page's content as its own.

Is there a way I can set a custom canonical URL for this page?

0 Likes
Shopify Partner
1346 22 208

I would not mess with the cannonical but rather set a no-index tag

{% if page.handle == 'mattress-store-los-angeles-ca' %}
  <META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW">
{% endif %}

This should go into <head>.

Same conditional thing can be done with the connonical URL.

https://sections.design tips, tricks & Shopify sections
0 Likes
New Member
3 0 0

Thanks for the help Mircea!

I will probably do both but definitely want to set the canonical tag.

Google is currently favoring the https://blissfulsleep.com/pages/mattress-store-los-angeles-ca page in search results and while noindex may do the trick, canonical will definitely do the trick.

I take it I need this code?

{% if page.handle == 'mattress-store-los-angeles-ca' %}
  <link rel="canonical" href="https://blissfulsleep.com/">
{% endif %}

Just wantd to double check before I input it.

Also, you said not to mess with the canonical tag? Was there a reason why? Was it because now the "https://blissfulsleep.com/pages/mattress-store-los-angeles-ca" page will have two canonical tags? If so, how do I remove the canonical tag on "https://blissfulsleep.com/pages/mattress-store-los-angeles-ca" that just points back to itself? If you check the page currently, there is a canonical tag there that just points right back to "https://blissfulsleep.com/pages/mattress-store-los-angeles-ca".

I hope that's not too confusing?

Thanks for all of your help!

0 Likes
New Member
3 0 0

Hey Mircea,

Any idea on this?

0 Likes
Tourist
11 0 2

Yes! I have the same question too!

Can anyone let us know if this code is right and where to paste to

{% if page.handle == 'mattress-store-los-angeles-ca' %}
  <link rel="canonical" href="https://blissfulsleep.com/">
{% endif %}

 

Thanks

Iky

0 Likes
Shopify Expert
9807 91 1558

The base concept is correct, but you won't be able to just paste that in. Your theme very likely already has code in place setting a canonical url so you don't want to have two tags. You'd want to find that and create and if/else conditional statement so that only the one shows.

 

First locate that section in your theme and reply back with the code - and surrounding parts. Each theme will have that code in a different spot and some seo apps will also add their own version instead. That makes it hard to direct your to the exact spot.

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
11 0 2

Thank you very much! I found your reply to another one!

It works perfectly with if/else! Thanks


@Jason wrote:

The base concept is correct, but you won't be able to just paste that in. Your theme very likely already has code in place setting a canonical url so you don't want to have two tags. You'd want to find that and create and if/else conditional statement so that only the one shows.

 

First locate that section in your theme and reply back with the code - and surrounding parts. Each theme will have that code in a different spot and some seo apps will also add their own version instead. That makes it hard to direct your to the exact spot.

 



, Jason! 

0 Likes
Tourist
5 0 1

This needs to be pasted just before the closing head tag </head>

0 Likes