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
-
Is a Wordpress AMP plugin sufficient, or should we upgrade our WP theme to an AMP theme?
Hello there, our site is on a Flatsome Wordpress theme (which is responsive and does not support AMP), and we are currently using the AMP for Wordpress plugin on our blog and other content rich pages. My question is - is a plugin sufficient to make our pages AMP friendly? Or should we consider switching to a theme that is AMP enabled already? Thanks!
Intermediate & Advanced SEO | | tnixis
Katie0 -
Title & Keywords
Hi Quick question on arrangement of keywords in titles. I know the order isn't so important anymore, but would there be a real issue if I want to rank for 'Henry Xtra' but my title reads 'Numatic Henry Xtra Vacuum Cleaner' Rather than 'Henry Xtra Vacuum Cleaner' ?? Will it really make much difference? Thank you!
Intermediate & Advanced SEO | | BeckyKey0 -
How would you address these URLS
Hey Mozzers, long time no post. Just a quick one for you regarding URLS, this is an example of a url on a site https://www.thisismyurl.co.uk/products/spacehoppers/special-spacehopper.html Many of these pages are getting flagged for having a url that is too long. The target of this page is "special spacehoppers". Should i be concerned with the url being to long given my keyword is at the end? Would this be a suitable idea? https://www.thisismyurl.co.uk/p/spacehoppers/special.html Would changing products to p be worthwhile? It would remove length from nearly all urls but would require a site wide re-direct. 2)Would removing the "spacehoppers" bit from the url be worth it? Yes it would shorten the url but would also remove the exact keyword from the url which could be detrimental to rankings.
Intermediate & Advanced SEO | | ATP0 -
We 410'ed URLs to decrease URLs submitted and increase crawl rate, but dynamically generated sub URLs from pagination are showing as 404s. Should we 410 these sub URLs?
Hi everyone! We recently 410'ed some URLs to decrease the URLs submitted and hopefully increase our crawl rate. We had some dynamically generated sub-URLs for pagination that are shown as 404s in google. These sub-URLs were canonical to the main URLs and not included in our sitemap. Ex: We assumed that if we 410'ed example.com/url, then the dynamically generated example.com/url/page1 would also 410, but instead it 404’ed. Does it make sense to go through and 410 these dynamically generated sub-URLs or is it not worth it? Thanks in advice for your help! Jeff
Intermediate & Advanced SEO | | jeffchen0 -
Redirecting to Modal URLs
Hi everyone! Long time no chat - hope you're all well! I have a question that for some reason is causing me some trouble. I have a client that is creating a new website, the process was a mess and I am doing a last minute redirect file for them (long story, for another time). They have different teams for different business categories, so there are multiple staff pages with a list of staffers, and a link to their individual pages. Currently they have a structure like this for their staff bios... www.example.com/category-staff/bob-johnson/ But now, to access the staffers bio, a modal pops up. For instance... www.example.com/category-staff/#bob-johnson Should I redirect current staffers URLs to the staff category, or the modal URL? Unfortunately, we are late in the game and this is the way the bio pages are set up. Would love thoughts, thanks so much guys!!
Intermediate & Advanced SEO | | PatrickDelehanty0 -
Is it bad I have a cluster of canonical urls that 301 re-direct?
Just went through a migration. We have a group of canonical URLs that are NOT the preferred url, but 301 re-direct to the preferred URL. Does this essentially "break even" and the incorrect canonical URL becomes obsolete? And/or would this be considered potentially bad and confusing for bots?
Intermediate & Advanced SEO | | lunavista-comm0 -
Tags: 301 Redirect, Rel Canonical, or Leave Them Alone?
The title is pretty self explanatory ... we have cornerstone pages ( such as a page for "Widget A") that rank for a certain keyword and then relevant articles that all link to that particular cornerstone page. Each of those articles has the same tag ("Widget A") to tie them together. If you click on that tag, it creates a list of all articles with that tag. We think that this may be siphoning off some of that keyword Google Juice from our Widget A cornerstone page. Our question is, should we 301 redirect that tag to point to the Widget A cornerstone page, use a rel canonical pointing to the Widget A cornerstone page, or just leave it alone like we are doing now? Our goal is to have the Widget A cornerstone page receive the most Google Juice possible and not be diminished by the tags. Note* - We don't want to stop Google from crawling the tags because some of our tags rank highly for other keywords. Also, we tried 301 redirecting the tags before and our ranking dropped significantly ... however, we made a lot of site changes at the same time so we are not sure if the drop in rank was due to redirecting the tags or the site changes. Help please ... thanks in advance 😉
Intermediate & Advanced SEO | | Humanovation0 -
Canonical Fix Value & Pointer To Good Instructions?
Could you tell me whether the "canonical fix" is still a relevant and valuable SEO method? I'm talking about the .htaccess (or ISAPI for Microsoft) level fix to make all of the non-www page URLs on a website redirect to the www. version - so that SEO "value" isn't split between the two. I'm NOT talking about the newer <rel= canonical="" http:="" ...="">tag that goes in the HEAD section on an HTML page - as a fix for some duplicate content issues (I guess). </rel=> I still hear about the latter, but less about the former. But the former is different than the latter right - it doesn't replace it? And I'm not sure if the canonical fix is relevant to a WordPress-based website - are you? Also I can never find any page or article on the Web, etc. that explains clearly how to implement the canonical fix for Apache and Microsoft servers. Could you please point me to one? Thanks in advance!
Intermediate & Advanced SEO | | DenisL0