Website translation

Applying rel=canonical Tags to Shopify: How & When

Applying rel=canonical Tags to Shopify: How & When
Rayne Aguilar
Written by
Rayne Aguilar
Rayne Aguilar
Written by
Rayne Aguilar
Reviewed
Rayne Aguilar
Reviewed by
Updated on
October 3, 2023

If you’re like the typical Shopify store owner, your shop probably stocks multiple variants of the same product. Some of your product pages may have similar product descriptions. You may even be posting promotional blog posts that include your standard store policies.

These are all perfectly fine content to have on your ecommerce store website. But you’ll need to implement code snippets called “canonical tags” containing “canonical URLs” to prevent them from potentially causing search engine optimization (SEO) issues.

That’s because they could contain duplicate content that hurt your store’s online search rankings.

In this guide, we’ll share what canonical URLs are, why they matter, and how you can add canonical tags to your Shopify store. And to end off, we’ll cover some best practices for implementing canonical tags and checking if they’re working as they should.

What are Canonical URLs?

If you’re an avid watcher of films and TV shows, or a book reader, you may be familiar with the concept of “canon.” This word refers to how a certain event is considered part of the official storyline or universe for a movie, TV show, or book.

For instance, boy wizard Harry Potter defeating the evil Lord Voldemort is part of the Harry Potter canon, as you can find this event in the books written by author J.K. Rowling. On the other hand, the idea of characters Hermione Granger and Draco Malfoy becoming a couple, though popular among some Harry Potter fans, is not canon.

Similarly, when it comes to technical SEO, a canonical link is a page URL that is considered the official, “master” copy of a web page.

Content can live almost word-for-word on multiple pages, such as:

  • https://example.com/blog/hello-world being the URL for the original web page.
  • https://example.com/blog/hello-world?utm_source=newsletter&utm_medium=email being the URL users are directed to when they click an email newsletter link to the original web page.
  • https://partnersite.com/blog/hello-world being the URL of a web page on a different website that contains syndicated content from the original page.

All these different URLs can potentially rank on Google and other search engines, so we’d need to indicate which is the canonical one. In doing so, we’ll be informing Google which URL we want it to rank in the search engine results pages (SERPs) over others.

Why Do Canonical Urls Matter?

By using canonical URLs, you’ll be able to:

  • Specify which URL searchers should see in the SERPs. As mentioned above, canonical URLs help search engines rank the URL that you consider the “master” URL for web pages with highly similar content. You can then use this canonical URL to direct searchers to the official version of your web page instead of non-canonical versions of it.
  • Prevent duplicate content issues that affect which pages Google displays on the SERPs. Google generally doesn’t penalize websites for having duplicate content on multiple pages. However, these similar pages could confuse Google over the best page to display on the SERPs. Designating a canonical URL will make it crystal-clear to Google which page it should rank. (We’ll cover duplicate content issues that could arise on a Shopify store later!)
  • Consolidate page rankings. If the URLs for your multiple similar pages start to pick up backlinks or other ranking signals, you can use a canonical URL to funnel these to your preferred URL for the page. As a result, you boost that URL’s rankings on the SERPs.
  • Track the performance of your content more easily. With Google directing users to content on a single URL instead of the same content on multiple URLs, monitoring views, clicks, and conversions for that content will be simpler.

How Do Canonical Urls and Canonical Tags Differ?

Don’t mix up canonical URLs with canonical tags! The latter term refers to the code snippet that’s added to pages to indicate their canonical URLs to search engines.

Canonical tags go in the header section of pages – in the <head> element, in other words – and look something like this:

	
  <link rel=“canonical” href=“https://example.com/blog/hello-world” />
  
 

In the above canonical tag, the canonical URL is “https://example.com/blog/hello-world”.

Every web page (including those built with Shopify) for which you want to indicate a canonical URL will need to have its own canonical tag. But no, you won’t have to add canonical tags to your Shopify pages one by one!

As you read on, we’ll share a tutorial for conveniently inserting canonical tags into all your Shopify pages with just one line of code.

How to Identify Duplicate Content Issues in Shopify

Duplicate content issues can appear on a Shopify store in various ways. Does your store suffer from any of these?

  • Displaying the same product pages on multiple different URLs. For example, your Shopify homepage, collection pages, and best sellers page may all be directing users to one particular product – albeit using different product URLs.
  • Different pages with very similar content. These can include products with almost-identical product descriptions, content being broken up into multiple separate pages (also known as pagination), and blog posts with repeated content.
  • Different versions of the same domain. For instance, although https://www.example.com, https://example.com, and https://example.com/index.html may all lead to your store’s homepage, search engines regard them as separate URLs for ranking purposes.

Allowing such duplicate content to remain on your Shopify website can dilute your ranking signals across multiple duplicate pages, harming your store’s ranking potential.

Let’s nip such duplicate content issues in the bud – even if they haven’t happened yet – by adding canonical tags to your Shopify store pages, and informing search engines which URLs they should display and rank on the SERPs!

How to Implement Canonical Tags in Shopify

1. Back Up Your Shopify Theme

This is an important first step whenever you edit your Shopify theme – which is what you’ll do when adding canonical tags to your store pages.

Backing up your theme will help you easily revert any changes you’ve made to a previous working version of your Shopify store. It’s a lifesaver if your website accidentally breaks while you’re implementing canonical tags.

So, from your Shopify admin dashboard, navigate to Sales channels in the left sidebar. Select Online Store > Themes.

Click the 3 horizontal dots beside the theme you want to edit, followed by Duplicate to make a copy of it.

Duplicate Shopify theme

2. Open Your Shopify Theme in the Code Editor

With the backup done, click the 3 horizontal dots next to your Shopify theme again. (Here, we’re referring to the Shopify theme you want to edit – not the backup you’ve just made.)

This time, select Edit code.

Doing so will open your Shopify theme in the code editor.

Edit Shopify theme code

3. Navigate to the Theme File That Contains Your Store’s Header Code

In the code editor, you’ll see a long list of theme files in the left sidebar. They can look intimidating, but you’ll just need to open the file containing the code for your Shopify pages’ <head> element.

This file is typically the “theme.liquid” one:

Shopify theme.liquid file

Click the “theme.liquid” file in the left sidebar and find the </head> tag in it. This tag is the opposite of the <head> tag and indicates the end of the <head> element.

</head> tag in Shopify theme.liquid file

If you don’t see either the <head> or </head> tags in your “theme.liquid” file, try asking your theme’s developer which theme file they’re in.

4. Insert the Canonical Tag

Just before the </head> tag – one line above it works well – type or paste in this canonical tag:

	
	  
  	<link rel="canonical" href="{{ canonical_url }}"/ >  
   
Canonical tag in Shopify theme.liquid file

{{ canonical_url }} is a code placeholder written in Shopify’s Liquid template language. When Shopify encounters this code on a page, it will dynamically generate a canonical URL for that page and replace {{ canonical_url }} with that URL.

And since the “theme.liquid” file controls the <head> element for all your Shopify store pages, inserting the above code snippet will give each page unique canonical URLs that point to themselves.

You won’t have to prepare and insert canonical tags for all your pages manually!

Click the “Save” button at the top right of the Shopify code editor to apply your changes.

5 SEO Considerations and Best Practices for Canonical Urls in Shopify

After implementing canonical URLs on your Shopify store, follow these 5 recommendations to ensure you’re using canonical URLs for the right purposes.

They’ll also help you get the most out of them:

1. Don’t Use Noindex to Mark Non-canonical Versions of Pages

The noindex directive tells Google not to index a specific page. Using it can seem intuitive if you don’t want a certain non-canonical page to appear in the SERPs, but doing so can cause unintended SEO issues.

Namely, you’ll prevent Google from indexing that page – or passing to another target page any ranking signals that page has gotten.

Using a canonical tag instead of the noindex directive will allow Google to index your page and understand that another page is meant to be the “official” version of it. Google can then also consolidate any ranking signals with that “official” page for you.

2. Don’t Use robots.txt for Canonicalization Either

Your Shopify store contains a robots.txt file that tells Google which of your store URLs it can (or cannot) access as it adds pages to its search index.

This file primarily helps with managing your crawl budget, and not canonicalization. If you add a page URL to your robots.txt file, Google will not be able to:

  • crawl its contents, or
  • assess the ranking signals the URL may have acquired – much less pass these on.

Google may also still display the “robotted” page on its SERPs with its meta description missing.

3. Understand When to Use 301 Redirects vs. Canonical Tags

Use 301 redirects if you want users to look at the content on a specific page URL instead of that on another URL. Through such redirection, you’ll prevent users and search engines from visiting the redirected page.

In contrast, canonical tags keep the pages containing them active, while telling search engines which version of the page they should index and rank.

4. Use Self-Referencing Canonicals

These are canonical tags on web pages that point to the pages’ own URLs as their canonical URLs.

For example, a self-referencing canonical tag for the “https://example.com/blog/hello-world” URL would contain “https://example.com/blog/hello-world” as its canonical URL.

It’s a good practice to include such self-referencing canonicals on all your Shopify store pages even if you don’t have any duplicate pages right now. That’s because you preemptively mitigate any duplicate content issues that could occur on your Shopify store in the future.

Alternatively, someone could scrape your store pages for publishing on their website without your knowledge. If they hadn’t altered your canonical tag in the process, search engines would still regard your page’s URL as the content’s original source and deprioritize ranking the scraped page.

(By following our tutorial above, you’ll have set up self-referencing canonicals on your Shopify pages!)

5. Audit Your Shopify Store’s Canonical Urls Regularly

You can use the Google Search Console to learn the versions of your store URLs that Google is indexing. Open the tool, then type the page URL you want to check into the URL inspection feature.

In the “Indexing” section of the inspection report, you’ll be able to see the:

  • canonical URL you’ve declared for the URL, also known as “user-declared canonical,” and the
  • Google-selected canonical, which is the URL that Google regards as the official version of the URL.

If there are discrepancies between your user-declared canonical and the Google-selected canonical, take steps to rectify the issue.

Conduct such audits regularly, especially if you’ve made significant changes to your Shopify store’s structure, product categories, or collection pages. By doing so, you’ll be able to spot – and fix – any potential canonical URL issues early.

Shopify SEO: What Else Do You Need to Do?

Implementing canonical tags may not be the highest item on your priority list as you operate a Shopify store. But doing so is quick, straightforward, and helps ensure that the right versions of your online store page URLs rank on the SERPs. So take a minute to add these handy tags to your Shopify theme as soon as you can!

If you’re running a multilingual Shopify store, installing canonical tags is but one Shopify SEO action item you’ll need to take care of. To deliver a good user experience, for example, you’ll also need to implement hreflang tags. These tags help signal to search engines the versions of your store pages to serve to users with certain language and geographical region settings.

In this regard, Weglot is an ideal solution for optimizing your Shopify store for international searches as it can help automatically implement hreflang tags on your store pages. It also includes useful functionality for:

  • translating your store content into over 110 supported languages, and
  • displaying these translations under language subdomains or subdirectories.

By using Weglot to optimize their Shopify stores, ecommerce businesses such as The Bradery and Ron Dorff have saved more than 100 hours in translation time, and reaped significant increases in traffic and international sales.

Keen to experience such benefits for your own store? Then sign up for a free 10-day Weglot trial here.

Discover weglot

Ready to display your website in multiple languages?

Try Weglot on your website for free (no credit card required).

Icon blog

In this article, we're going to look into:
Try for free