New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonical not working #6327

youngnaturists opened this Issue Dec 25, 2016 · 7 comments


None yet
5 participants

youngnaturists commented Dec 25, 2016

What did you expect to happen? When we place the canonical in the field in the back-end, it should generate a canonical tag in the source code.

What happened instead? The URL we enter still shows up in the canonical field, but there's no tag.

How can we reproduce this behavior? In the edit page of a post, in the Yoast SEO box, go to the Canonical URL field under "Advanced", enter URL, click update. The URL appears in the field, but when you go to view source, there is no canonical tag (new or old).

Can you provide a link to a page which shows this issue? We placed a canonical in the back end of this page: pointing it here: (and it doesn't appear in source code)

Technical info

  • WordPress version:
  • Yoast SEO version:

This comment has been minimized.


stodorovic commented Dec 27, 2016

I just checked your website. I saw following in HTML source:

URL .../feminism-womens-issues/page/2/:

<!-- This site is optimized with the Yoast SEO plugin v4.0.2 - -->
<title> .... 2</title>
<meta name="description" content="..."/>
<meta name="robots" content="noindex,follow,noodp"/>
<meta name="keywords" content="..."/>
<link rel="prev" href=".../feminism-womens-issues/" />
<link rel="next" href=".../feminism-womens-issues/page/3/" />

I don't see canonical and og:url tags. It's weird and it seems as conflict with some plugin or the theme. You can see that exists next and prev URLs.
I see that sitemap doesn't contain first URL (where you have manually set canonical URL) which works as should.

I'm copying message related to plugin conflicts:
Sometimes strange behavior may be caused by a plugin or theme conflict. The fastest way to rule out conflicts is to deactivate all non-Yoast plugins and switch to a standard theme like Twenty Sixteen. If this resolves the issue, you have a conflict and should activate one plugin at a time until you locate the conflict. Finally, after all plugins are active, switch to your theme. This will narrow down the conflict to a specific plugin or a theme conflict.

If you are unfamiliar with checking for conflicts, we wrote a small guide that will walk you through the steps. You can find it here:

We understand if you wouldn't want to deactivate your plugins and switch themes on a production site, so it may be preferable that you set up a staging environment for your tests.

If you're not familiar with a staging site, this article will help you get started:

Can you please inform us of the results?


This comment has been minimized.

youngnaturists commented Dec 28, 2016

We did as suggested with testing for conflicts, but came up with nothing... :( So what do you suggest?


This comment has been minimized.


stodorovic commented Dec 28, 2016

I can reproduce your issue if I add following code:

add_filter( 'wpseo_opengraph_url', '__return_false' );
add_filter( 'wpseo_canonical', '__return_false' );

Basically, I can't see your code and it's hard to find this. Also, I don't know your versions of WP, PHP and other plugins. I see that you have customized theme.

The best which I can suggest is to you create PHP script (eg. canonical-test.php) with following content:


// require wordpress
define('DOING_AJAX', false);
define('WP_USE_THEMES', true);
define('QM_DISABLED', true);
define('DONOTCACHEPAGE', true);

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
define('WP_DEBUG_LOG', false);

$_SERVER['REQUEST_URI']    = '/';

// Load the WordPress library.
require_once( dirname(__FILE__) . '/wp-load.php' );                
// Set up the WordPress query.
// basic init for templates
do_action( 'template_redirect' );
echo '<pre>';

global $wp_filter;
echo "Debug info for filters\n";
if ( isset( $wp_filter['wpseo_canonical'] ) ) {
  var_dump( $wp_filter['wpseo_canonical'] );

echo "Try to init Yoast\n";

echo "Test Yoast API\n";
echo "Canonical URL\n";
$url = $wpseo_front->canonical( false, true, true );
var_dump( $url );
echo '</pre>';

Upload it in your root directory (where is index.php, wp-load.php,...), Then try to run this script by typing http://....../canonical-test.php It shows debug info for wpseo_canonical hook (possible root of this issue) and then try to run canonical with $no_override = true which shows URL regardless previous filter.

PS. I don't know your knowledge of PHP, FTP,... Maybe it's too complex test. You can install Query monitor or debug objects (it doesn't work on WP 4.7) for more debugging.


This comment has been minimized.


CarolineGeven commented Jan 20, 2017

I want to apologize for not getting back to you any sooner, @youngnaturists. Unfortunately we cannot reproduce this issue.

If I understand correctly you've checked for a plugin conflict. Did you check for a theme conflict as well? As this is such a specific issue and we're not sure if this bug could be present on other people's sites, please check this article we've written about writing a bug report.

Please let us know if the issue still persists with a theme such as twentysixteen or twentyseventeen.


This comment has been minimized.


CarolineGeven commented Feb 10, 2017

Closing due to inactivity. If this issue is still relevant, please respond with requested information.


This comment has been minimized.

cborchert commented Mar 30, 2018

Just wanted to contribute here, because this is relatively high on the google search results, and while hopefully @youngnaturists has resolved this issue, I'm hoping to help people with the same issue in the future.

Before checking for plugin and theme conflicts, please simply check whether the setting Discourage search engines from indexing this site under Settings > Reading is checked. If it is checked, you will likely see <meta name="robots" content="noindex,follow"> in your site's header, and it seems that there will be no canonical url set by Yoast SEO.


This comment has been minimized.

born2webdesign commented Sep 19, 2018

I am seeing this on one of my sites, too—on my local test site and on the corresponding online test site (copied with Duplicator). Other websites (same version of WordPress and Yoast SEO) are fine, on the same local machine, too.
A bespoke theme as well as twentyseventeen are affected.
It does work fine (canonical shown) with all plugins activated, until I activate Yoast—that makes the canonical disappear (only on this one site).
I have diffed all the Yoast files against the ones of another working site—all of them are identical!
Also optimized the database with WP-Optimize (just for good measure).
So I don't know what to try next …

WordPress 4.9.8
Yoast SEO 8.2

The script from @stodorovic does show the canonical:

Debug info for filters
Try to init Yoast
Test Yoast API
Canonical URL
string(21) "https://example.test/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment