A canonical link (often referred to as a “canonical tag” or “rel canonical”) is an HTML element that helps webmasters prevent duplicate content issues in search engine optimisation (SEO) by specifying the “canonical” or “preferred” version of a web page. It’s a way of telling search engines that certain similar URLs are equivalent, but one is the primary version.
Here’s why it’s useful?
Imagine you have a piece of content accessible under multiple URLs (website addresses) or even multiple websites. Without a way to consolidate these URLs, search engines might treat them as separate, unique pages, which can lead to issues like diluted page rank or the wrong version of the page being indexed.
The canonical tag addresses this problem by allowing webmasters to indicate to search engines which version of a page they’d prefer to have indexed. This is especially important for websites with dynamic URLs or for sites that serve the same content through multiple URLs.
The canonical tag looks like this in the <head> section of a webpage:
html
<link rel=”canonical” href=”https://example.com/page/” />
In this example, even if there are multiple URLs displaying the content found at https://example.com/page/, this tag tells search engines that the aforementioned URL is the master copy or canonical version of the page.
Some common scenarios where canonical links come in handy include:
HTTP and HTTPS duplicates
If a site can be accessed by both HTTP and HTTPS URLs.
www and non-www duplicates
For example, example.com vs. www.example.com.
Dynamic URLs
If the same content can be accessed via different URLs due to URL parameters like sorting or filtering options.
Syndicated Content
If content is republished across different websites or platforms.
By using canonical tags appropriately, webmasters can help ensure that search engines understand which pages they consider to be the authoritative versions, leading to better and more accurate indexing and ranking in search results.
How to prevent duplicate content issues in WordPress, especially as they pertain to canonical links, here’s a step-by-step guide
Use an SEO Plugin
One of the easiest ways to manage canonical URLs in WordPress is by using an SEO plugin. Some popular options are:
Yoast SEO
Once installed, this plugin will automatically set canonical URLs for your content. If you need to specify a custom canonical URL for a particular post or page, you can do so from the Yoast meta box directly on the post/page editing screen.
All in One SEO Pack: Like Yoast, this plugin will handle canonical URLs for you. Custom canonical URLs can also be specified if needed.
Ensure Consistent URL Structure:
Avoid using both www and non-www versions of your site. Decide which one you prefer and then set up a 301 redirect for the other.
Choose either a trailing slash or no trailing slash for your URLs and stick with it.
Use the WordPress “Settings” > “Permalinks” option to ensure you have a clean, consistent URL structure for your posts and pages.
Avoid Duplicate Content:
If you have content that’s accessible in multiple categories or tags, it could result in duplicate content. Ensure your SEO plugin is set to add a canonical link to these pages.
Limit the content shown on archive, category, and tag pages by showing excerpts instead of full content to minimise the amount of duplicate content.
Manage Other Sources of Duplicate Content:
If using paginated comments, ensure there’s a canonical tag pointing back to the main post or page.
For e-commerce sites or others that may use URL parameters for sorting and filtering, ensure those URLs have canonical tags pointing back to the main category or product page.
Custom Canonical Links
If you need to manually add a canonical link to a post or page, you can do so by adding the following code to your theme’s header.php file, within the <head> tags:
php
Copy code
<?php
if (is_single() || is_page()) {
$canonical_url = get_permalink();
echo ‘<link rel=”canonical” href=”‘ . esc_url($canonical_url) . ‘” />’;
}
?>
Regularly Monitor & Check Your Site:
Use Google Search Console to check for any duplicate content issues or warnings related to canonical URLs.
Use SEO audit tools or plugins to routinely check your site for any potential duplicate content issues.
Remember, while canonical tags are a powerful tool for signalling to search engines which version of a content you deem most authoritative, the best way to prevent duplicate content issues is to be consistent and thoughtful about your site’s structure and content from the start.
