Website content

How to Apply Canonical URLs When Generating Website Content

Image source: Getty Images

Canonical URLs can solve duplicate content and crawl issues to improve your SEO. Find out if you need them and how to get them.

Don’t worry, canonical URLs have nothing to do with guns and war. Derived from the word canon, which refers to a commonly shared principle or law, a canonical URL indicates your preferred version among duplicate web pages. This allows search engines to optimally crawl, index and interpret your website content.

Overview: What is a Canonical URL?

Canonical URLs are about being on the same page as search engines. Literally. It is a small piece of source code inserted into a web page that directs search engines to the page they should display when there are multiple versions of the same page or content.

How does a canonical URL affect SEO?

The value of a canonical URL for SEO lies in the control it gives you over what content on your website is visible to search engines. Canonical URLs allow you to:

  • Avoid multiple versions of the same content being indexed
  • Free up crawl budget to index important pages
  • Make sure the most prominent URL is indexed for duplicate content

How to Implement Canonical URLs When Generating Content for Your Website

The first thing to do when implementing canonical URLs is to create a sitemap of your referring URLs and submit it through Google Search Console and other webmaster tools. But this is not always enough.

URL canonicalization can be done in different ways depending on how your website is set up and how the website was built. Often your site will be built with a content management system (CMS) such as WordPress or Wix or an online store builder such as Shopify or Squarespace. Each system handles and creates URLs differently.

CMS software is getting better at handling URLs and can provide a shortcut for implementing canonical URLs.

Let’s walk through the steps for implementing canonical URLs.

1. Check your canonicity

Ideally, you should start by performing an SEO audit to determine if canonical URLs are already implemented and will contribute to better SEO performance.

If you have a problem with duplicate content or a problem with search engines indexing all your pages, it’s worth fixing. You can use an SEO tool to crawl your site for duplicate content and check if you already have canonical tags in place.

Screenshot of the results page of a duplicate content checker.

Hive Digital’s free duplicate content tool allows you to quickly check for duplicate content without performing a full audit. Image source: author

2. Identify referring URLs and canonicalization rules

Next, we need to identify the way to canonize. If you only look at a few URLs, the solution is simple. You simply set the canonical URL, referencing the originating page, and note the page(s) that require canonicalization with a line of code inserted.

But in many cases, you will find that your site is filled with different versions of pages. In this case, you may need to design rules and have a developer implement the tags. The rules can be as simple as https://www.yourdomain.com/homepage/1/ and https://www.yourdomain.com/homepage/2/ and all the others https://www.yourdomain.com/homepage/n/ where ‘n’ is a number, must refer https://www.yourdomain.com/homepage/ as the correct URL.

Another common case is that an e-commerce website allows many different views of the same content using parameters in the URL. For example, you might have a product page named summer dress/ and the e-commerce website creates individual URLs for each color of the dress, such as summer dress/blue/ and summer dress/pink/. In this case, the rule will be to reference the summer dress/ URL as canonical URL for all pages.

3. Decide how to implement

The easiest way to implement canonical URLs is to insert a line of code with the rel=canonical instruction in the section of each page. Via a CMS, there are often plugins or native functions to implement them on your entire site.

For more complex implementations, you can ask your developer to find the best method based on the rules and the list of canonical instances you identified in the previous step.

Other implementations for canonical URLs exist. It is possible to provide them in the HTTP header by modifying a file called .htaccess. It’s not too complicated but if you make mistakes in the file, your whole site will stop working and provide a server error. Handle with Care.

Finally, it is possible to obtain canonical effects without tags. As mentioned at the beginning, you can achieve some of your goals simply by providing a sitemap to search engines. It is also possible to use 301 duplicate URL redirects to primary URLs when neither users nor search engines need the duplicates.

Illustration of a canonical URL implementation.

First, identify where you need canonical URLs, then implement them using the rel=canonical code. Image source: author

4. Check the impact

After implementation, you should verify that the canonical tags appear as they should by examining the source code of some of the pages that contain duplicate content.

It may take search engines a while to reflect the changes as they have to crawl and index the pages first. You may be able to speed it up by submitting URLs to search engines for duplicates, but you can also just let them re-crawl pages naturally.

You should also be able to see the effect in Google Search Console under the Coverage menu. Check if the list of valid URLs contains the pages you want to index and if the list of excluded URLs does not contain valid pages.

If you still don’t see any changes in the crawl patterns through Search Console after a few weeks, you may need to check the implementation again.

3 best practices when using canonical URLs

You can get away with a spelling mistake or a grammatical imperfection in a written text. Readers will always understand your message. However, the same is not true for coding. Make sure your code is 100% correct and you are using the correct URL incorporating your main domain name.

Let’s look at other best practices for using canonical URLs.

1. Use Absolute Lowercase URLs

In HTML, it is possible to refer to another page via relative or absolute paths.

Absolute path: https://www.domain.com/page/

Relative path: /page/

It is recommended to use the absolute URL with the full path. To avoid confusion, also keep lowercase for URLs. From a technical point of view, uppercase and lowercase characters are different, although most web servers treat them the same. Also remember to always use HTTPS rather than HTTP if you have a secure server certificate. This avoids additional duplicate content issues.

2. Implement canonical URLs on all pages

In theory, you only need canonical URLs on duplicate pages, but implementing them on all pages is probably easier. It is also considered a best practice. The main page to which the other pages refer will contain the statement rel=canonical indicating its own URL.

3. Avoid Multiple Canonical Tags

Coding multiple canonical tags can be done quite easily, as they can be implemented at different levels. If a canonical URL is given in the HTTP header, it should not be mentioned in the part of the page.

More importantly, there shouldn’t be two canonical tags on the same page. This will only confuse search engine crawlers and cause them to ignore statements completely.

Canonical URLs can never hurt

Not having canonical URLs on a website per se is not a problem. But if your SEO suffers from duplicate content or incomplete crawl issues, canonical URLs can help solve the problem.

In other cases, it may provide a marginal SEO improvement and is therefore considered an SEO best practice. For large or multilingual sites, canonical URLs are an absolute must.