Syndicate

Feed

Using canonical links in Shopify

While a few Shopify shop-owners have elevated their concern with search engine optimization to an obsessive-compulsive disorder while waiting for their sales to pick up, the word is out that we can use the link element to tell search engines about duplicate content. The idea is that we don't want search engines to dilute the ranking of a product page among the many different URLs by which said page can be accessed. The dilution is further aggravated when a product belongs to many collections: the same content we see at /products/my-lovely-boyfriend-is-for-sale will be seen at /collections/SOME_COLLECTION/products/my-lovely-boyfriend-is-for-sale and /collections/SOME_OTHER_COLLECTION/products/my-lovely-boyfriend-is-for-sale. You get these last two URLs if you use the within filter in your collection and index templates. You can learn how to navigate within a collection by visiting Shopify's wiki.

We add a canonical link to a web page when we don't want it indexed. We don't want it indexed because we know the same content can be found somewhere else, and we use the canonical link to tell the spider where to find the one 'true' page, that is, the page we do want indexed, cherished and behold. For the sake of simplicity, the one true page for Shopify product pages is the one sitting under /products/MY-PRODUCT. You'll find at this URL the collection-agnostic landing page for your product.

In Shopify, adding a canonical link for product pages is very simple. Open theme.liquid and locate your head element. Anywhere between the opening and closing tag of the head element, paste this code:

{% if template == 'product' %}{% if collection %}
<link rel="canonical" href="{{ shop.url }}{{ product.url }}" />
{% endif %}{% endif %}

The noindex instruction

As a bonus question: what if you want to ask a spider to not index a webpage, yet have nothing else to offer in its place?

Shopify keeps the legs of well-behaved spiders off some of the content of your website by supplying a nice instruction booklet under SHOPNAME.myshopfy.com/robots.txt. The content of that file is:

# robots.txt file for www.shopify.com e-commerce engine
 
User-agent: *
Disallow: /admin
Disallow: /carts
Disallow: /orders
Sitemap: http://SHOPNAME.myshopify.com/sitemap.xml
 
User-agent: Nutch
Disallow: /

Shopify also tells the well-behaved spiders what to index in SHOPNAME.myshopfy.com/sitemap.xml. You have nothing to do here. It's all taken care of for you. Also, you can't edit robots.txt, and cannot easily provide an alternate sitemap — not sure why you would want to do that, but it needed to be said.

What if there are pages that you do not want spiders to get their legs on? For example, what if you don't want product-type collections to get indexed?

Answer: Open theme.liquid and locate your head element. Anywhere between the opening and closing tag of the head element, paste this code:

{% if template == 'collection' %}{% if collection.handle %}{% else %}
<meta name="robots" content="noindex,follow" />
<!-- instructs search engines not to index this page, but to follow links from the page -->
{% endif %}{% endif %}

How does that work? The collections that live under /collections/types?q=PRODUCT TYPE have no collection handle.

Last edited by Caroline Schnapp about 5 years ago.

Comments

Does it matter?

To answer the question Does it matter that we get duplicate content in Shopify? I would say: Not Really. We're certainly not getting penalized for it. Search engines will not wave their finger at us. It is typical of any good content management system (and any good e-commerce site does manage content) to present quasi-similar content. Why so? Because of categorization. In Drupal, we call categorization taxonomy. Let me give you an example. Last night, I wrote a post about canonical links. Never wrote about canonical links before in my life, so I tagged my post with new Tag canonical link. This morning, if you're googling for Shopify canonical link, the first two hits point to my website. The first hit points to the post itself at http://11heavens.com/using-canonical-links-in-Shopify. The second hit points to the category page that was automatically created with my Tag: http://11heavens.com/taxonomy/term/321. Both pages present almost-identical content.

hmmm...

I would say that unless google starts getting harsher that this would be more of an exercise. I believed you but googled it anyway to see for myself and I am not sure at this point that it would be worth retofitting Shopify sites I have done. However, for the hell of it I guess I will start this moving forward, just as a good practice. So thanks for the tips once again!

Just an exercise

This is only an exercise. It matters very little. I've just given some more tools for the SEO 'experts' out there to charge even more money to go in and paste code they don't even understand and that won't make a difference —other than in their own pocket. I am not kidding you. Damn, I really should become a SEO expert myself.

Great information you got

Great information you got here. I’ve been reading about this topic for one week now for my papers in school and thank God I found it here in your blog. I had a great time reading this .

siding repair maryland

I would really appreciate

I would really appreciate the efforts you all have made here to make this page more informative. Thanks again. That is some inspirational stuff. Never knew that opinions could be this varied.While a few Shopify shop-owners have elevated their concern with search engine optimization to an obsessive-compulsive disorder while waiting for their sales to pick up, the word is out that we can use the link element to tell search engines about duplicate content.
UK DVD Online Store

It doesn't matter but a good lesson none the less

According Google webmaster guidelines, they will only index one page if they find more than one identical page. But I suppose the reason this is so important is for two reasons.

One, to account for non-Google search engines. Second, to choose which page (URL) you want to have indexed.

Nice write up Caroline.

Glad to have found the

Glad to have found the information matching my criteria. This will really help me in completing my work easily and on time. Thanks for sharing.

easy jailbreak iphone 4s help

This subject has impressed

This subject has impressed me for quite some time. I have just started researching it on the Internet and found your post to be informative
Click here

I wish that was true

According Google webmaster guidelines, they will only index one page if they find more than one identical page.

What they say they'll do, and what they do is different. I did not believe it myself until I saw it with my own eyes. Google _does_ index pages that are perfectly identical in content.

You always got to one up me, huh?

This is very true. I suppose, I was taking them for their word, but after look at searches for site:mydomain.com I do notice some of the same pages, which proves your point, but I'm just not going to take the time to look over 300 pages of results.

My only question would be, would any pages slip through the cracks or is this solid?

Not sure I understand your question

My only question would be, would any pages slip through the cracks or is this solid?

Slip through the cracks of what?

Interesting

I will be honest, I had no idea what a canonical link was till reading the article.

Thanks

use UNLESS

Thanks for good tips.

Instead of
{% if collection.handle %}{% else %}
<meta name="robots" content="noindex,follow" />
{% endif %}

it's easier to read
{% unless collection.handle %}
<meta name="robots" content="noindex,follow" />
{% endif %}

Much improved, yes.

Agreed, Andrei.

See below v

oops endunless


{% unless collection.handle %}
<meta name="robots" content="noindex,follow" />
{% endunless %}

Thank you

That's a common 'oops' to use endif with unless. In Ruby, you would simply use end. Other common 'oops' is to use elseif instead of elsif in Liquid (but, there, Ruby is the same, not different).

By the way, do you know if we can use and and or with unless, like so:

{% unless something == 'this' or something == 'that' %}
..
{% endunless %}

Will check.

Thanks for dropping by.

Apply to Pages?

Hi,

I am using pages as additional text blocks and further description elements for a product page and would like to block the individual pages (read as: design elements) from being indexed.

Would this code prevent indexing of all pages?

{% if template == 'page' %}
<meta name="robots" content="noindex,follow" />
<!-- instructs search engines not to index this pages -->
{% endif %}

If so, great but then how could I prevent indexing of all pages EXCEPT a few like 'About Us' or 'Contact'

Thanks for any thoughts...

If so, great but then how

If so, great but then how could I prevent indexing of all pages EXCEPT a few like 'About Us' or 'Contact'

You could use something like this:

{% if template == 'page' and page.handle != 'about-us' and page.handle != 'contact' %}
<meta name="robots" content="noindex,follow" />
<!-- instructs search engines not to index this pages -->
{% endif %}

This is great

Caroline,

Thanks for this post, very useful for someone with very little idea about coding. I have implemented in to my store as willing to give anything a go.

We saw a dramtic increase in our tarffic to our shopify store after making a few changes and submitting our sitemap to Google Webmaster Central. Since the googlebots have been back out however our duplicate titles and descriptions have gone from 60 to 212 and we have almost automatically lost the traffic again.

I appreciate your comments that duplicates don't necessarily matter however I can't see any other reason for such a dramatic drop in our traffic.

The pages that google are identifying are confusing me as when I view the code the meta descriptions aren't duplicated following changing our product descriptions.

Any suggestions for help would be fantastic

Thanks

Claire

If you want your Canonical link to be the long url...

If you want your canonical link to be the url that contains the collection name, and assuming each product is only in a single collection, then the following code should work: (If products are in multiple collections, then the canonical link will point to the first collection in the list):

    {% if template == 'product' %}   
        {% if product.collections %}
        <link rel="canonical" href="{{ shop.url }}{{product.collections.first.url}}{{ product.url }}" />
        {% endif %}
    {% endif %}

Robots and ?constraint=

Hi All,

So after reading this post and also the Collections info on the Shopify forum, I just wanted to confirm that the inclusion of:

{% if template == 'collection' %}{% if collection.handle %}{% else %}

{% endif %}{% endif %}

Will ensure that the URL for each collection page that has ?constraint= appended at the end, will NOT be indexed by the search engines (but links will be followed)? Is that correct?

Thanks in advance :)

Tag to prevent indexing of Tagged blog pages

Hi. Your article is very informative. I am not a Shopify coder so I'm
I want to prevent the "tagged" generated pages in blogs from being indexed.
This is a sample path below of one of those pages made up of articles in buzz-news tagged with signed cookbooks.
/blogs/buzz-news/tagged/signed-cookbooks
I want the blog URLs indexed (all the articles and main pages), but not the tagged sets of articles.
What would I use to prevent those "tagged" generated pages?

Your help is appreciated.

The better optimization is

The better optimization is this code?:

{% if template == 'product' %}{% if collection %}

{% endif %}{% endif %}
{% if template == 'collection' %}

{% endif %}

I don't want duplications.

Thanks

unique web info.

I like this weblog its a master peace or unique. Glad I found this on google search. I just wanted to give you a quick heads up! Other then that.

...Blog/Tagged/...

Is it this code ok?

{% if template == 'blog' %}{% if blog.url contains 'tagged' %}

{% endif %}{% endif %}