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 availability
Hi We have a website selling cellphones. They are available in different colors and with various data capacity, which slightly changes the URL. For instance: Black iphone, 16GB: www.site.com/iphone(black,16,000000000010204783).html White iphone, 16GB: www.site.com/iphone(white,16,000000000010204783).html White iphone, 24GB: www.site.com/iphone(white,24,000000000010204783).html Now, the canonical URL indicates a standard URL: But this URL is never physically available. Instead, a user gets 301 redirected to one of the above URLs. Is this a problem? Does a URL have to be "physically" available if it is indicated as canonical?
Intermediate & Advanced SEO | | zeepartner0 -
Rel=canonical
My website is built around a template, the hosting site say I can only add code into the body of the webpage not the header, will this be ok for rel=canonical If it is my next question is redundant but as there is only one place to put it which urls do I need to place in the code http://domain.com, www.domain.com or http://www.domain.com the /default.asp option for my website does not seem to exist, so I guess is not relevant thanks
Intermediate & Advanced SEO | | singingtelegramsuk0 -
Difference in Number of URLS in "Crawl, Sitemaps" & "Index Status" in Webmaster Tools, NORMAL?
Greetings MOZ Community: Webmaster Tools under "Index Status" shows 850 URLs indexed for our website (www.nyc-officespace-leader.com). The number of URLs indexed jumped by around 175 around June 10th, shortly after we launched a new version of our website. No new URLs were added to the site upgrade. Under Webmaster Tools under "Crawl, Site maps", it shows 637 pages submitted and 599 indexed. Prior to June 6th there was not a significant difference in the number of pages shown between the "Index Status" and "Crawl. Site Maps". Now there is a differential of 175. The 850 URLs in "Index Status" is equal to the number of URLs in the MOZ domain crawl report I ran yesterday. Since this differential developed, ranking has declined sharply. Perhaps I am hit by the new version of Panda, but Google indexing junk pages (if that is in fact happening) could have something to do with it. Is this differential between the number of URLs shown in "Index Status" and "Crawl, Sitemaps" normal? I am attaching Images of the two screens from Webmaster Tools as well as the MOZ crawl to illustrate what has occurred. My developer seems stumped by this. He has submitted a removal request for the 175 URLs to Google, but they remain in the index. Any suggestions? Thanks,
Intermediate & Advanced SEO | | Kingalan1
Alan0 -
Pagination, Canonical Tag & Best Practices
I have an eCommerce site that dynamically creates category pages, which produce canonical tags in the header. For multiple page categories, it adds the page number to the URL. For example, this category has 3 pages.... Because most categories have too many products, I can't follow Googles suggestion of creating a "view all" page. Furthermore since all these pages use the same template, I'm unable to insert a NOINDEX tag in all the pages after the first page. Also, in this scenario, I'm unable to insert the discreet code for Next/Previous, which is also suggested by Google. My only option for maintaining these dynamically generated category pages would be to hardcode the first conical tag in the template, which would then be produced on all subsequent paginated pages. Consequently, every paginated page in this category would have the same canonical tag pointing to the first page. Would this incur the wrath of Google and would I'd be better off leaving the pagination they way it is?
Intermediate & Advanced SEO | | alrockn0 -
Ecommerce product URLs & flat architecture?
Hey Mozzers, I'm optimizing a small ecommerce site. The site URL directory structure seems all good & logical, BUT should I try for a flatter architecture - so that the individual products are at top level after the domain name in URLs? e.g.
Intermediate & Advanced SEO | | GregDixson
www.domain.com/first-item/
www.domain.com/second-item/
etc. etc. My current setup (I'm using the Woocommerce plugin in Wordpress): www.domain.com/shop/ (main shop page)
www.domain.com/shop/category-name-1/
www.domain.com/shop/category-name-2/
www.domain.com/shop/category-name-3/ with products appearing as:
www.domain.com/product/first-item/
www.domain.com/product/second-item/
etc. I've researched some big brand ecommerce sites and most seem to be domain.com/amazing-product/ even if the product itself is many categories or sub-categories down. i.e. Homepage > Home & Furniture > Furniture > Living Room Furniture > Coffee Tables As I say the information architecture makes sense from a user point of view, but I'm guessing the individual products would stand more chance of ranking if directly following the domain name? Woocommerce although flexible doesn't seem to do this out-of-the-box, so please some advice before I go on a hacking and URL rewriting mission! Thanks 🙂0 -
Overly-Dynamic URL
Hi, We have over 5000 pages showing under Overly-Dynamic URL error Our ecommerce site uses Ajax and we have several different filters like, Size, Color, Brand and we therefor have many different urls like, http://www.dellamoda.com/Designer-Pumps.html?sort=price&sort_direction=1&use_selected_filter=Y http://www.dellamoda.com/Designer-Accessories.html?sort=title&use_selected_filter=Y&view=all http://www.dellamoda.com/designer-handbags.html?use_selected_filter=Y&option=manufacturer%3A&page3 Could we use the robots.txt file to disallow these from showing as duplicate content? and do we need to put the whole url in there? like: Disallow: /*?sort=price&sort_direction=1&use_selected_filter=Y if not how far into the url should be disallowed? So far we have added the following to our robots,txt Disallow: /?sort=title Disallow: /?use_selected_filter=Y Disallow: /?sort=price Disallow: /?clearall=Y Just not sure if they are correct. Any help would be greatly appreciated. Thank you,Kami
Intermediate & Advanced SEO | | dellamoda2 -
Canonical VS Rel=Next & Rel=Prev for Paginated Pages
I run an ecommerce site that paginates product pages within Categories/Sub-Categories. Currently, products are not displayed in multiple categories but this will most likely happen as time goes on (in Clearance and Manufacturer Categories). I am unclear as to the proper implementation of Canonical tags and Rel=Next & Rel=Prev tags on paginated pages. I do not have a View All page to use as the Canonical URL so that is not an option. I want to avoid duplicate content issues down the road when products are displayed in multiple categories of the site and have Search Engines index paginated pages. My question is, should I use the Rel=Next & Rel=Prev tags on paginated pages as well as using Page One as the Canonical URL? Also, should I implement the Canonical tag on pages that are not yet paginated (only one page)?
Intermediate & Advanced SEO | | mj7750 -
Does rel=canonical fix duplicate page titles?
I implemented rel=canonical on our pages which helped a lot, but my latest Moz crawl is still showing lots of duplicate page titles (2,000+). There are other ways to get to this page (depending on what feature you clicked, it will have a different URL) but will have the same page title. Does having rel=canonical in place fix the duplicate page title problem, or do I need to change something else? I was under the impression that the canonical tag would address this by telling the crawler which URL was the URL and the crawler would only use that one for the page title.
Intermediate & Advanced SEO | | askotzko0