The Internet Marketing Driver

  • GSQi Home
  • About Glenn Gabe
  • SEO Services
    • Algorithm Update Recovery
    • Technical SEO Audits
    • Website Redesigns and Site Migrations
    • SEO Training
  • Blog
    • Web Stories
  • Contact GSQi

How To Remove Rel Canonical From Noindexed Pages In WordPress Using The All In One SEO Plugin [Tutorial]

July 12, 2017 By Glenn Gabe 7 Comments

Share
Tweet
Share
Email
716 Shares

How to remove rel canonical from noindexed pages.

When performing SEO audits, it’s not unusual to surface pages being noindexed that also contain rel canonical. And that setup does’t make sense. Using the meta robots tag or x-robots-tag with noindex tells the engines to not index the page, while rel canonical tells the engines which is the preferred url for indexing. You can end up sending Google very confusing signals. Google’s John Mueller has explained this many times in the past and it could lead to some strange results.

Here are some links where John has mentioned this before:
https://www.seroundtable.com/noindex-canonical-google-18274.html
https://www.seroundtable.com/archives/020151.html

John Mueller explains that it’s best to not mix rel canonical and noindex (at 56:59 in the video):

And in an SEO world where certain things are out of your control, I’m a firm believer in taking control where you can. This is one of those situations. I always recommend that clients send the strongest signals possible about which pages should be indexed, and which ones shouldn’t be indexed. And providing both rel canonical and noindex definitely sends mixed signals.

SEO WordPress Plugins and Relinquishing Control
Many site owners using WordPress utilize SEO plugins to handle various tasks. For example, optimizing titles and metadata, managing indexation of different page categories, and more. But since the plugins are created by third parties, there are times it’s hard to customize your setup. And that can leave you with holes in your SEO armor.

One extremely popular SEO plugin, which I’ve used for a long time, is the All In One SEO Plugin, or AIOSEOP for short. It’s a plugin that has over three million active installs. There is also a pro version with additional functionality (and that’s what I’m running now). I’ve found the plugin to be extremely helpful for managing SEO tasks on WordPress sites.

All In One SEO Plugin

I love the plugin, but for whatever reason, it always added rel canonical to noindexed pages. For example, if you noindex your categories or archive pages, rel canonical was still added. If you noindexed a certain post or page, rel canonical was added there too. This was definitely a thorn in my side, especially knowing that it’s best to not include rel canonical on noindexed pages.

It bugged me enough that I decided to find a solution.

Reaching Out To The AIOSEOP Team
I reached out to the All In One SEO Plugin team to see if there was a solution for handling this. I received an email back quickly with a nifty solution. It ends up you can use filter hooks to refine how the All In One SEO Plugin handles various situations. In a nutshell, by adding some code to your functions.php file, you can customize your setup. This is exactly the type of customization I was looking for.

So I fired up a text editor, opened my functions.php file and started testing some functions for handling rel canonical and noindex on certain page types. Below, I’ll cover how you can implement the same thing on your WordPress site.

How To Use Hooks To Remove Rel Canonical From Noindexed Pages
The code that handles this customization is pretty straight forward. You’ll add a filter via one line of code and then the function that removes rel canonical based on the condition that’s met. For my example, I wanted to remove rel canonical from any category or archive page, since those pages are currently being noindexed.

Here’s how to set this up:

  1. Back up your WordPress blog. Any time you are going to mess with your WP code, you should absolutely back up everything. Make sure you can easily revert to the latest version. I automatically back up my blog daily and I also have my hosting provider backing up my entire site daily.
  2. Open the functions.php file for your theme. It should be located in your theme’s root directory. If you have no idea what I’m referring to, then speak with your developer or hosting provider about finding the right file. If you want to learn more about functions.php, you can check out this article on wpbeginner.com.
  3. Back up your current functions.php file before adding the new code. This is a great way to ensure you have a stable version of the file that you can revert back to, if needed. Simply download the file, save a backup, and then come back to the original file to customize the code.
  4. Add the following code to your functions.php file. It checks if the current page is a category page or archive page and doesn’t write out rel canonical in the html if it is.

add_filter('aioseop_canonical_url','remove_canonical_url', 10, 1);
function remove_canonical_url( $url ){
global $post;
if( is_category() ){
return false; // Remove the canonical URL for categories.
} elseif (is_archive() ){
return false; // Remove the canonical URL for archives.
}
return $url;
}

  1. Upload the functions.php file to your site (again, in your theme’s root directory). If you aren’t sure where this file should go, seek help first. Don’t just start uploading the file to different areas of your WordPress install.
  2. Test the code by visiting your category pages or archive pages. If the code works, you should NOT see rel canonical being written out in the html. You should just see the meta robots tag using noindex.
    Only publishing noindex without rel canonical.
  3. You’re not done testing yet. Double check your homepage, your blog posts, and your pages to ensure rel canonical IS being written out properly. You want to make sure there’s not a conflict with other plugins or with your theme, which could result in some funky behavior.
  4. If all looks good, then you’re all set! You can rest assured that your category and archive pages are not providing both rel canonical and the meta robots tag using noindex.

You Can Handle Noindexed Pages and Posts Too
Even though the code I provided above handles categories and archived pages, you can absolutely tailor the code to handle any page or post. You could provide additional conditions via the same function to remove rel canonical from specific pages or posts based on their ID.

For example, you could add the following code to the function we created earlier to check for a specific post. Just add another elseif that checks for a post ID:

elseif ( $post->ID === 2){
return false; // Remove the canonical URL for post #2.
}

Summary – Rel canonical and noindex don’t mix.
If you’re using the All In One SEO Plugin, then this is a great solution for making sure rel canonical and noindex aren’t mixed together on the same page. Again, that can send mixed signals to Google. This technique can be used for major page types like categories or archives, as well as for specific pages or posts. Sure, you’ll need to edit some code, but it’s a flexible solution that shouldn’t take very long to set up.

Like I said earlier, don’t send mixed signals to Google. Take control and send clear signals instead.

GG

 

Share
Tweet
Share
Email
716 Shares

Filed Under: google, seo, tools

Connect with Glenn Gabe today!

Latest Blog Posts

  • Continuous Scroll And The GSC Void: Did The Launch Of Continuous Scroll In Google’s Desktop Search Results Impact Impressions And Clicks? [Study]
  • How to analyze the impact of continuous scroll in Google’s desktop search results using Analytics Edge and the GSC API
  • Percent Human: A list of tools for detecting lower-quality AI content
  • True Destination – Demystifying the confusing, but often accurate, true destination url for redirects in Google Search Console’s coverage reporting
  • Google’s September 2022 Broad Core Product Reviews Update (BCPRU) – The complexity and confusion when major algorithm updates overlap
  • Google Multisearch – Exploring how “Searching outside the box” is being tracked in Google Search Console (GSC) and Google Analytics (GA)
  • Sitebulb Server – Technical Tips And Tricks For Setting Up A Powerful DIY Enterprise Crawler (On A Budget)
  • Google’s Helpful Content Update Introduces A New Site-wide Ranking Signal Targeting “Search engine-first Content”, and It’s Always Running
  • The Google May 2022 Broad Core Update – 5 micro-case studies that once again underscore the complexity of broad core algorithm updates
  • Amazing Search Experiments and New SERP Features In Google Land (2022 Edition)

Web Stories

  • Google’s December 2021 Product Reviews Update – Key Findings
  • Google’s April 2021 Product Reviews Update – Key Points For Site Owners and Affiliate Marketers
  • Google’s New Page Experience Signal
  • Google’s Disqus Indexing Bug
  • Learn more about Web Stories developed by Glenn Gabe

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • August 2021
  • July 2021
  • June 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • GSQi Home
  • About Glenn Gabe
  • SEO Services
  • Blog
  • Contact GSQi
Copyright © 2023 G-Squared Interactive LLC. All Rights Reserved. | Privacy Policy
This website uses cookies to improve your experience. Are you ok with the site using cookies? You can opt-out at a later time if you wish. Cookie settings ACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience. You can read our privacy policy for more information.
Cookie Consent