How to apply canonical URLs when generating website content

smiling young woman standing behind the counter in a cafe

Image Source: Getty Images

Canonical URLs can fix duplicate content and crawling 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 firearms and warfare. 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 indexing multiple versions of the same content
  • Free up crawl budget to index important pages
  • Make sure the most important 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 achieved in a couple of different ways depending on your website setup and how the website was created. Often your site will be built with a content management system (CMS) like WordPress or Wix or an eCommerce store builder like Shopify or Squarespace. Each system manages and creates URLs differently.

CMS software is getting better at handling URLs and can provide a shortcut to implement canonical URLs.

Let’s review the steps to implement canonical URLs.

1. Check your canonicality

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

If you have a duplicate content issue or a problem getting search engines to index all of your pages, then this is worth addressing. 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 how to canonicalize. If you’re looking for just a few URLs, the solution is simple. Simply define the canonical URL, referencing the original page, and annotate the page(s) that need canonicalization with a line of code inserted.

But in many cases, you’ll find that your site is full of 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/ Y https://www.yourdomain.com/homepage/2/ and everyone else https://www.yourdomain.com/homepage/n/ where ‘n’ is a number, you must reference https://www.yourdomain.com/homepage/ as the correct URL.

Another common case is that an e-commerce website will allow many different views of the same content through the use of parameters in the URL. As an example, you could have a product page called Summer dress/ and the e-commerce website creates individual URLs for each color of the dress, such as summer dress/blue/ Y summer dress/pink/. In this case, the rule will be to refer to the Summer dress/ URL as the canonical URL for all pages.

3. Decide on the mode of implementation

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. Through a CMS, there are often plugins or native features that allow you to implement them on your site.

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

There are other implementations for canonical URLs. 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 entire site will crash and give a server error. Handle with Care.

Finally, it is possible to achieve canonical effects without tags. As mentioned at the beginning, you can accomplish some of your goals simply by providing a sitemap to search engines. It is also possible to use 301 redirects from duplicate URLs to primary URLs when the duplicates are not needed by users or search engines.

Illustration of a canonical URL implementation.

First, identify where you need the canonical URLs, and then implement them using the rel=canonical tag. Image Source: Author

4. Check the impact

After implementation, you should verify that the canonical tags appear as they should by looking at the source code for some of the pages that have duplicate content.

Search engines may take a while to reflect the changes, as they must first crawl and index the pages. You may be able to speed it up by submitting URLs to search engines for duplicates, but you can also just let them recrawl the 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 any valid pages.

If you still don’t see any change in crawl patterns through Search Console after a few weeks, you may need to check your implementation one more time.

3 best practices when using canonical URLs

You can get away with a misspelling or a grammatical imperfection in the typed text. Readers will still understand your message. However, it is not the same for encoding. Make sure your code is 100% correct and that you are using the correct URL that embeds your primary domain name.

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

1. Use lowercase absolute URLs

In HTML, it is possible to refer to another page through 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 any confusion, keep the URLs lowercase as well. From a technical perspective, uppercase and lowercase characters are different, although most web servers treat them the same way. Also, remember to consistently use HTTPS instead of 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 the canonical URLs on the duplicate pages, but implementing them on all pages is probably easier. It is also considered good practice. The parent page referenced by other pages will contain the rel=canonical statement indicating its own URL.

3. Avoid multiple canonical tags

Encoding of multiple canonical tags can happen quite easily, as they can be implemented at various levels. If a canonical URL is indicated in the HTTP header, it must not be mentioned in the page section.

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 the claims entirely.

Canonical URLs can never hurt

Not having canonical URLs on a website itself is not a problem. But if your SEO is struggling with duplicate content or incomplete crawling, canonical URLs can help fix the problem.

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