How to Add Canonical Tags in WordPress to boost your SEO by Michael Scaramozzino

How to Add Canonical Tags in WordPress to Boost Your SEO

How to Add Canonical Tags in WordPress with or Without Plugins to Boost Your SEO Rankings

Today I’ll show you how to add canonical tags in WordPress to boost your SEO rankings. First we’ll define what canonical tags are. Next we’ll look at why canonical tags are important for SEO. Then we’ll see how to add canonical tags in WordPress using WordPress plugins. Finally we’ll show how to add canonical tags in WordPress without plugins.


What are Canonical Tags?

Canon: An authoritative principal or rule.

Canonical Name (CNAME): A domain name system (DNS) record associating an alias to the primary host name.

Canonical Tag: A meta tag indicating the URL to the original source web page of content that is duplicated.

A canonical tag is a meta tag that specifies the primary URL that points to the original web page containing content that may be duplicated on other webpages elsewhere. So a duplicated web page or post may contain a canonical tag that points to the URL of the original webpage that contains that same content.

A self-referential canonical tag indicates the primary URL to use for a web page that is accessible via various alternate URLs. For instance posts in WordPress may be accessed via the post’s primary permalink or via alternate URLs such as a category, archive or tag URL.

Here is a simple example of a canonical tag that might appear in the header of a webpage for this post.

<link rel=”canonical” href=”https://dreamlight.com/how-to-add-canonical-tags-in-wordpress/” />

Why are Canonical Tags Important for SEO?

If the same content appears on multiple webpages, or if it is accessible via multiple URLs, then those multiple hits may compete with each other and dilute the search engine rankings of that content. Not only does duplicate content dilute your SEO rankings but search engines may also indirectly “penalize” duplicate content by listing duplicate hits only under the “show similar” links and by lowering your rank in other ways. You can boost the search engine rankings of the original source webpage by using canonical tags on the duplicated content. Just point the canonical tag to the URL of the original source webpage. This way the search engines know which page to index and which to skip.

Also, using self-referential canonical tags on any webpages that may be accessible via alternate URLs will avoid having those alternate URLs dilute your main URLs search engine rankings. As a result, self-referential canonical tags can strengthen the search engine rankings of your webpages.


How to Add Canonical Tags in WordPress with Plugins

There are various WordPress plugins that can automatically add canonical tags to your webpages. One popular SEO plugin that we often use is Yoast SEO. The Yoast SEO plugin automatically adds self-referential canonical tags to WordPress pages and posts. You may also override the default self-referential permalink canonical tags in Yoast SEO.

How to add canonical tags in wordpress with Yeost SEO plugin

 


How to Add Canonical Tags in WordPress without Plugins

Below is a simple example of how to add self-referential canonical tags in WordPress multi-site without using plugins. Simply add this php code to the header.php template file. The particular WordPress multi-site used in this example has a sub-directory domain structure.

<!-- Self referential canonical tag on all pages -->
<?php
   if ( is_front_page() ) {
      $canonical_url = get_home_url();
      if ( ! is_main_site() ) { // add trailing slash for subsite home directories
         $canonical_url = $canonical_url . '/';
      }
   } else {
      $canonical_url = get_permalink();
   }
?>
<link rel="canonical" href="<?php echo $canonical_url ?>" />

On a non-multi-site WordPress site you may skip the test for ( ! is_main_site() ) and the php code would look like the simplified sample below.

<!-- Self referential canonical tag on all pages -->
<?php
   if ( is_front_page() ) {
      $canonical_url = get_home_url();
   } else {
      $canonical_url = get_permalink();
   }
?>
<link rel="canonical" href="<?php echo $canonical_url ?>" />

DreamLight Can Design a Custom WordPress Web Site for You

New WordPress Website SampleDreamLight can develop a custom WordPress website for you. We can work closely with your marketing team to update your existing Web site that may be outdated or to design a brand new custom WordPress website. In addition to leveraging SEO as discussed above, we design all our custom WordPress websites to be fully responsive. As a result the overall design layout automatically re-flows on-the-fly to take advantage of modern mobile devices. As multimedia experts we can also create a wide range of integrated branded marketing content for your website to help it really stand out, including: 2D/3D digital design, illustration, animation, interactive multimedia or even web application development.

Contact us for more information about designing a custom WordPress website or to explore your specific needs.


Request a Free Quote Today!

DreamLight brings your dreams to light – digitally.


If you enjoyed this tutorial please consider making a donation to fund more!


DreamLight wrote the book: Creating a 3D Animated CGI Short. See what we can do for you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.