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
-
Fetch & Render
Hi I've done Google fetch & render of this page & I have images which Google/customers aren't seeing - how do I identify the problems with this page? http://www.key.co.uk/en/key/chairs
Intermediate & Advanced SEO | | BeckyKey1 -
Href Lang & Canonical Tags
Hi I have 2 issues appearing on my site audit, for a number of pages. I don't think I actually have an issue but just want to make sure. Using this page as an example - http://www.key.co.uk/en/key/0-5-l-capacity-round-safety-can-149p210 The errors I get are: 1. Conflicting hreflang and rel=canonical Canonical page points to a different language URL - when using href & canonicals, it states I need a self referential canonical . The page above is a SKU page, so we include a canonical back to the original model page so we don't get lots of duplicate content issues. Our canonical will point to - http://www.key.co.uk/en/key/justrite-round-safety-cans 2. No self referencing hreflang. Are these big issues? I'd think the bigger issue would be if I add self referencing canonicals and end up with lots of duplicate content. Any advice would be much appreciated 🙂
Intermediate & Advanced SEO | | BeckyKey0 -
Ecommerce, SEO & Pagination
Hi I'm trying to workout if there's something wrong with our pagination. We include the rel="next" and "prev" on our pages. When clicking on page 2 on a product page, the URL will show as something like - /lockers#productBeginIndex:30&orderBy:5&pageView:list& However, if I search site:http://www.key.co.uk/en/key/lockers in Google, it seems to find paginated pages: http://www.key.co.uk/en/key/lockers?page=2 I have a feeling something is going wrong here, but haven't worked massively on Pagination before. Can anyone help?
Intermediate & Advanced SEO | | BeckyKey0 -
Rel Canonical attribute order
So the position of the attribute effect the rel canonical tags' ability to function? is the way I see it across multiple documents and websites. Having a discussion with someone in the office and there is a website with it set up as: Will that cause any problems? The website is inquestion still has both pages indexed within Google using the SITE:domain.com/product as well as SITE:domain.com/category/product
Intermediate & Advanced SEO | | jasondexter0 -
Should we use URL parameters or plain URL's=
Hi, Me and the development team are having a heated discussion about one of the more important thing in life, i.e. URL structures on our site. Let's say we are creating a AirBNB clone, and we want to be found when people search for apartments new york. As we have both have houses and apartments in all cities in the U.S it would make sense for our url to at least include these, so clone.com/Appartments/New-York but the user are also able to filter on price and size. This isn't really relevant for google, and we all agree on clone.com/Apartments/New-York should be canonical for all apartment/New York searches. But how should the url look like for people having a price for max 300$ and 100 sqft? clone.com/Apartments/New-York?price=30&size=100 or (We are using Node.js so no problem) clone.com/Apartments/New-York/Price/30/Size/100 The developers hate url parameters with a vengeance, and think the last version is the preferable one and most user readable, and says that as long we use canonical on everything to clone.com/Apartments/New-York it won't matter for god old google. I think the url parameters are the way to go for two reasons. One is that google might by themselves figure out that the price parameter doesn't matter (https://support.google.com/webmasters/answer/1235687?hl=en) and also it is possible in webmaster tools to actually tell google that you shouldn't worry about a parameter. We have agreed to disagree on this point, and let the wisdom of Moz decide what we ought to do. What do you all think?
Intermediate & Advanced SEO | | Peekabo0 -
Alternative to rel canonical?
Hello there, we have a problem. Let's say we have a website www.mainwebsite.com Then you have 40 websites like this: www.retailer1.mainwebsite.com www.retailer2.mainwebsite.com www.retailer3.mainwebsite.com www.retailer4.mainwebsite.com www.retailer5.mainwebsite.com www.retailer6.mainwebsite.com … an so on In order to avoid the duplicate content penalty from Google we've added a rel="canonical" in each 40 sub-websites mapping each page of them to www.mainwebsite.com Our issue is that now, all our retailers (each owner of www.retailer-X.mainwebsite.com) are complaining about the fact that they are disappeared from Google. How can we avoid to use rel="canonical" in the sub-website and not being penalised by Google for duplicate content in www.mainwebsite.com? Many thanks, all your advices are much appreciated. YESdesign team
Intermediate & Advanced SEO | | YESdesign0 -
Wordpress access denied
In Google Webmaster tools after doing a Google Fetch for our Blog which is showing Access Denied for 900+ pages this is the report that comes up and I wonder if this is causing the 900+ pages to show "Access Denied" and if so how to rectify it? The page seems to redirect to itself. This may result in an infinite redirect loop. Please check the Help Center article about redirects.```
Intermediate & Advanced SEO | | NileCruises
<code>HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Location: http://nile-cruises-4u.co.uk/blog/
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Thu, 05 Jul 2012 07:04:05 GMT
Content-Length: 157 <title>Document Moved</title> Object Moved This document may be found here I</code>0 -
Should we block urls like this - domainname/shop/leather-chairs.html?brand=244&cat=16&dir=ascℴ=price&price=1 within the robots.txt?
I've recently added a campaign within the SEOmoz interface and received an alarming number of errors ~9,000 on our eCommerce website. This site was built in Magento, and we are using search friendly url's however most of our errors were duplicate content / titles due to url's like: domainname/shop/leather-chairs.html?brand=244&cat=16&dir=asc&order=price&price=1 and domainname/shop/leather-chairs.html?brand=244&cat=16&dir=asc&order=price&price=4. Is this hurting us in the search engines? Is rogerbot too good? What can we do to cut off bots after the ".html?" ? Any help would be much appreciated 🙂
Intermediate & Advanced SEO | | MonsterWeb280