Yoast & rel canonical for paginated Wordpress URLs
-
Hello, our Wordpress blog at http://www.jobs.ca/career-resources has a rel canonical issue since we added pagination to the front page and category-pages. We're using Yoast and it's incorrectly applying a rel-canonical meta tag referencing page 1 on page 2, 3, etc. This is a known misuse of the rel-canonical tag (per Google's Webmaster Blog - http://googlewebmastercentral.blogspot.ca/2013/04/5-common-mistakes-with-relcanonical.html, which says rel-canonical should be replaced with rel-prev and rel-next for page 2, 3, etc.).
We don't see a way to specify anywhere in Yoast's options to correct this behaviour for page 2, 3, etc. Yoast allows you to override a page's canonical URL, otherwise it automatically uses the Wordpress permalink.
My question is, does anyone know how to configure Yoast to properly replace rel-canonical tags with rel-prev and rel-next for paginated URLs, or do I need to look at another plugin or customize the behavior directly in my child theme code?
This issue was brought up here as well: http://moz.com/community/q/canonical-help, but the only response did not relate to Yoast.
(We're using Wordpress 3.6.1 and Yoast "Wordpress SEO" 1.4.18)
-
Thanks for posting this Shaun! People actually do come back and read these months to come and these Q&A's will return in search results, so you've made this a really valuable page for future readers - thanks!
-Dan
-
I've now fixed this issue by refactoring our child theme so the WP queries occur before the header (inserting the content later).
Because we're using a custom homepage template for the front page and a custom "category page" template, I've also had to modify Yoast's "canonical" and "adjacent_rel_links" functions to understand the pagination for those pages (otherwise Yoast simply detects these as "singular" pages and only applies the rel canonical pointing to page 1, regardless of the current page).
I used the following code to allow overriding Yoast in my child-theme's functions.php:
if (defined('WPSEO_VERSION')) {
function custom_wpseo_override() {global $wpseo_front;
remove_action('wpseo_head', array($wpseo_front, 'canonical'), 20);
add_action('wpseo_head', 'custom_wpseo_canonical', 20);
remove_action('wpseo_head', array($wpseo_front, 'adjacent_rel_links'), 21);
add_action('wpseo_head', 'custom_wpseo_adjacent_rel_links', 21);
}
add_action('init','custom_wpseo_override');
} -
Shaun
Great, thanks - happy to help!
-Dan
-
Hi Dan,
Yeah it must me some kind of conflict with the theme or another plugin... We're not using Thesis or Genesis but we have modified header.php in our child theme to replace the masthead markup (just stuff within the body tag). I just noticed the other day that both the theme (ExtraNews by ThemeForest) and Yoast are adding their own <title>tags, so there may be more conflicts than one.</p> <p>Marking your response as an answer because you proved that Yoast can insert the rel next & prev tags and you've helped me get to the point where I'm 80% sure it's a theme conflict. Thanks again!</p></title>
-
Hi Shaun
Yes in terms of keeping strictly to Google's guidelines, I agree that Yoast should in theory use either prev/next or canonical on subpages, but not both.
I am honestly not certain the settings it could be otherwise, as "subpages of archives" is the only one I know of that handles pagination.
Could there be another plugin or your theme (or custom coding in header.php) causing a conflict? One thing you can do is shut off other plugins one by one to diagnose. You can switch themes or switch to the default header.php file included with WordPress, but I (for obvious reasons) do NOT recommend doing that on a live website. I'm not sure if you have a testing environment.
Are you using a framework like Thesis or Genesis? Sometimes those can cause unexpected things to happen as well.
-Dan
-
Hi Dan, and thanks very much for your response.
Per your screenshot, I believe it's not ideal that there's a rel canonical meta-tag pointing to the current partial page (page 2).
From the Google blog link above: "In cases of paginated content, we recommend either a rel=canonical from component pages to a single-page version of the article, or to use rel=”prev” and rel=”next” pagination markup."
They mention here https://support.google.com/webmasters/answer/1663744?hl=en (2nd last point) that it's optional to include a rel canonical tag like yours, but without the "Noindex subpages of archives" option enabled, it would probably cause your separate post pages to be indexed, which may or may not be ideal for you depending on how authoritative/complete each individual page's content is.
Yoast is definitely adding the rel prev & next meta-tags for you though, which is exactly what I need (minus the rel canonical). I wonder which exact setting is enabling that for you... We have very few Yoast options enabled/configured at all currently, but I don't see any that are specific to the rel prev & next tags.
I've tried enabling the "Noindex subpages of archives" per your suggestion, but it didn't result in any change in the meta-tags for my site (verified after caches cleared too).
Any other suggestions you have would be great. My colleagues want to keep Yoast for it's other features, so I may go the route of forking/modifying the Yoast plugin code to fit our situation if needed.
Thanks for your time!
-
Hi Shaun
Dan here, one of the Moz Associates - we're very sorry for the delay!
I've attached a screenshot of my own personal company site which uses the Yoast Plugin - just want to verify the code as seen here is what I would consider "correct" and best practice for WordPress pagination.
That code has not require any custom coding or anything. So either we need to get the Yoast settings correct, or something else may be interfering with Yoast.
Please first try going to: Yoast SEO->Titles/Meta and select "Noindex subpages of archives". This to my knowledge is the only setting that needs to be made to handle pagination correctly.
Let us know if that works - and again, apologies for the delay. Sometimes we have quite a backlog and don't pick up right away if the community has not appropriately answered a question.
Thanks!
-Dan
-
Do the 30+ people who've viewed this question think it answered itself? I tried to be thorough, but was it too much to read? Or... Is this not a great place to ask such a question?
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Canonical URL's searchable in Google?
Hi - we have a newly built site using Drupal, and Drupal likes to create canonical tags on pretty much everything, from their /node/ url's to the URL Alias we've indicated. Now, when I pull a moz crawl report, I get a huge list of all the /node/ plus other URL's. That's beside the point though... Question: when I directly enter one of the /node/ url's into a google search, a result is found. Clicking on it redirects to the new URL, but should Google even be finding these non-canonical URL's?? I don't feel like I've seen this before.
Intermediate & Advanced SEO | | Jenny10 -
DeIndexing pagination
I have a custom made blog with boat loads of undesirable URLs in Google's index like this:
Intermediate & Advanced SEO | | Rich_Coffman
.com/resources?start=150
.com/resources?start=160
.com/resources?start=170 I've identified this is a source of duplicate title tags and had my programmer put a no index tag to automatically go on all of these undesirable URLs like this: However doing a site: search in google shows the URLs to still be indexed even though I've put the tag up a few weeks ago. How do I get google to remove these URLs from the index? I'm aware that the Search Console has an answer here https://support.google.com/webmasters/topic/4598466?authuser=1&authuser=1&rd=1 but it says that blocking with meta tags should work. Do I just get google to crawl the URL again so it sees the tag and then deindexes the URLs? Or is there another way I'm missing.0 -
Rel=Alternate on Paginated Pages
I've a question about setting up the rel=alternate & rel=canonical tags between desktop and a dedicated mobile site in specific regards to paginated pages. On the desktop and mobile site, all paginated pages have the rel=canonical set towards a single URL as per usual. On the desktop site though, should the rel=alternate be to the relevant paginated page on the mobile site (ie a different rel=alternate on every paginated page) or to a single URL just as it is vice versa. Cheers chaps.
Intermediate & Advanced SEO | | eventurerob1 -
Yoast Wordpress SEO premium
As anyone installed Yoast Wordpress SEO premium. Love to ear some feedbacks. I have some problems on installations that i am trying to solve as i am not an expert on SEO.
Intermediate & Advanced SEO | | maestrosonrisas0 -
Are these URLs too Keyword-packed?
Hi guys, Here is the URL: http://www.consumerbase.com/mailing-lists/dog-stores-mailing-list.html The target keywords are "Dog stores mailing list" and "Dog stores mailing lists" Does having "mailing-list" and "mailing-lists" in my URL hurt me?
Intermediate & Advanced SEO | | Travis-W0 -
Is it ok to add rel=CANONICAL into the desktop version on top of the rel="alternate" Tag (Mobile vs Desktop version)
Hi mozzers, We launched a mobile site a couples months ago following the parallel mobile structure with a URL:m.example.com The week later my moz crawl detected thousands of dups which I resolved by implementing canonical tags on the mobile version and rel=alternate onto the desktop version. The problem here is that I still also got Dups from that got generated by the CMS. ?device=mobile ?device=desktop One of the options to resolve those is to add canonicals on the desktop versions as well on top of the rel=alternate tag we just implemented. So my question here: is it dangerous to add rel=canonical and rel=alternate tags on the desktop version of the site or not? will it disrupt the rel=canonical on mobile? Thanks
Intermediate & Advanced SEO | | Ideas-Money-Art0 -
Canonical referencing and aspx
The following pages of my website all end up at the same place:
Intermediate & Advanced SEO | | IPROdigital
http://example.com/seo/Default.aspx
http://example.com/SEO/
http://example.com/seo
http://example.com/sEo
http://example.com/SeO but we have a really messy URL structure throughout the website. I would like to have a neat URL structure, including for offline marketing so customers can easily memorize or even guess the URL. I'm thinking of duplicating the pages and canonical referencing the original ones with the messy URLs instead of a 301 redirect (done for each individual page of course), because the latter will likely result in a traffic drop. We've got tens of thousands of URLs; some active and some inactive. Bearing in mind that thousands of links already point in to the site and even a small percentage drop in traffic would be a serious problem given low industry margins and high marketing spend, I'd love to hear opinions of people who have encountered this issue and found it problematic or successful. @randfish to the rescue. I hope.0 -
Is it OK to have a site that has some URLs with hyphens and other, older, legacy URLs that use underscores?
I'm working with a VERY large site that has recently been redesigned/recategorized. They kept only about 20% of the URLs from the legacy site, the URLs that had revenue tied to them, and these URLs use underscores. Whereas the new URLs created for the site use hyphens. I don't think that this would be an issue for Google, as long as the pages are of quality, but I wanted to get everyone's opinion on this. Will it hurt me to have two different sets of URLs, those with using hyphens and those using underscores?
Intermediate & Advanced SEO | | Business.com0