WordPress SEO by Yoast
Duplicate content issue with 'enforce a trailing slash' a (7 posts)

  1. drrxa
    Posted 3 years ago #

    WordPress version: 3.4.1
    WordPress SEO version: 1.2.4

    I did this: Check the "Enforce a trailing slash on all category and tag URL's" and use pagination for some posts.

    I expected the plugin to do this: Add trailing slash only to categories and tags URLs.

    Instead it did this: Add trailing slash to sub-pages of paginated posts also, this happened lately, which creates two versions of each sub-page in Google index, one with the trailing slash and one without as follows:


    I am looking for advice here, I am aware that unchecking this option might resolve the issue by creating a 301 redirect from the "/" version to the non-"/" version, but I would prefer keeping the trailing slash for categories and tags and removing it for sub-pages of the paginated articles.



  2. Joost de Valk
    Plugin Author

    Posted 3 years ago #

    Hmm I wonder why it doesn't add it consistenly for paginanted posts and pages, that's what it should do.

  3. Joost de Valk
    Plugin Author

    Posted 3 years ago #

    Fixed for the next release, it won't add slashed on those anymore :)

  4. drrxa
    Posted 3 years ago #

    Thanks Joost, you are the best :) Waiting for the next release.

  5. Joost de Valk
    Plugin Author

    Posted 3 years ago #

    You can try the development version if you want to test it. You can download the development version from here, or you can download it directly here.

  6. drrxa
    Posted 3 years ago #

    Hi Joost, thanks for prompt updating, now the URLs for sub-pages of paginated posts does not have the trailing slash, but the canonical and the rel-next and rel-prev link tags still points to the slash version of the URL.

    URL: http://example.com/post/2
    link rel="canonical" href="http://example.com/post/2/"
    link rel="prev" href="http://example.com/post"
    link rel="next" href="http://example.com/post/3/"

    The Categories and Tags URLs and their link tags are working properly.

    URL: http://example.com/category/first-category/
    link rel="canonical" href="http://example.com/category/first-category/"
    link rel="next" href="http://example.com/category/first-category/2/"
  7. drrxa
    Posted 2 years ago #

    A temporary solution for the above problem using wpseo filters. I used the following code in the functions.php file:

    // Remove the trailing slash from the canonical URL of the sub-pages of paginated posts
    function remove_canonical_trailing_slash($url) {
    	if (is_singular()) {
    		return untrailingslashit($url);
    	} else {
    		return $url;
    // Remove the trailing slash from the URL of the next and prev link tags of sub-pages of paginated posts
    function remove_nxtprv_trailing_slash($linktag) {
    	if (is_singular()) {
    		return str_replace('/"', '"', $linktag);
    	} else {
    		return $linktag;

    Hope this is helpful.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress SEO by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.