Canonical Order

May 20, 2023

Canonical order refers to the standard ordering of entities, such as web pages or URLs, within a given system. It is a method used to define the preferred or primary version of a web page or URL, and to differentiate it from any alternate or duplicate versions.

Purpose

The main purpose of canonical order is to help search engines identify the most relevant and authoritative version of a web page or URL. When multiple versions of the same content exist, search engines may have difficulty determining which version to include in their index, resulting in duplicate content issues and potentially lower search rankings.

By establishing a canonical order, website owners can tell search engines which version of a page or URL is the preferred or primary version, and which other versions should be considered duplicates or alternate versions. This can help ensure that search engines index the correct version of a page, and avoid penalties for duplicate content.

Usage

There are several methods that can be used to implement canonical order, depending on the type of content and the platform used. Some of the most common methods include:

1. Canonical URLs

Canonical URLs are a type of URL that is used to identify the preferred or primary version of a web page. This is typically done by adding a special tag to the HTML of the page, which tells search engines that this is the canonical version of the page.

For example, if a website has two versions of the same page – one at “example.com/page” and another at “example.com/page?ref=123” – the canonical URL tag would be added to the “example.com/page” version of the page, indicating that this is the preferred version.

<link rel="canonical" href="https://www.example.com/page" />

2. Redirects

Redirects are another method that can be used to establish canonical order. This involves redirecting any alternate versions of a page or URL to the preferred or primary version, using a 301 redirect.

For example, if a website has a page at “example.com/page” and another at “example.com/page?ref=123”, a 301 redirect would be used to redirect the second URL to the first URL.

RewriteEngine On
RewriteCond %{QUERY_STRING} ref=123
RewriteRule ^page$ /page? [R=301,L]

3. Parameter handling

In some cases, websites may have multiple versions of a page that differ only by a single parameter, such as a session ID. In these cases, canonical order can be established by handling the parameter in a consistent manner, such as by always removing it or always adding it.

For example, if a website has a page at “example.com/page” that generates a session ID parameter, the canonical order could be established by always removing the session ID parameter when it is not needed.

if (isset($_SESSION['id'])) {
    $page_url = 'https://www.example.com/page?id=' . $_SESSION['id'];
} else {
    $page_url = 'https://www.example.com/page';
}

4. Content management systems

Many content management systems (CMS) have built-in features for establishing canonical order. These may include options to set the canonical URL for a page or to automatically handle duplicate content issues.

For example, in WordPress, the Yoast SEO plugin allows users to set the canonical URL for a page or post, as well as to automatically handle duplicate content issues.