WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 8 days ago

#28081 accepted defect (bug)

Do a canonical redirect for pages when query var 'paged' is set

Reported by: ocean90 Owned by: SergeyBiryukov
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Canonical Keywords: has-patch has-unit-tests SEO
Focuses: Cc:

Description

Example: http://make.wordpress.org/core/features-as-plugins/page/2323/

You can append /page/{any number} to a page and still get the same content as http://make.wordpress.org/core/features-as-plugins/

The same doesn't happen for posts.

trunk/src/wp-includes/canonical.php#L274: Seems like l274 and l276 should be !is_singular() as it was before [6115]. (Block was changed in [9697].)

Want to use this ticket to get some reasons for [6115]. Currently I only can think of custom page templates which are using a custom pagination, so maybe wontfix.

Attachments (2)

28081.patch (787 bytes) - added by ocean90 4 years ago.
28081.diff (1.7 KB) - added by peterwilsoncc 3 months ago.

Download all attachments as: .zip

Change History (30)

This ticket was mentioned in IRC in #wordpress-dev by ocean90. View the logs.


4 years ago

@ocean90
4 years ago

#3 @wonderboymusic
3 years ago

  • Keywords has-patch added; dev-feedback removed
  • Milestone changed from Awaiting Review to 4.0

This ticket was mentioned in IRC in #wordpress-dev by DrewAPicture. View the logs.


3 years ago

#5 @DrewAPicture
3 years ago

  • Milestone changed from 4.0 to Future Release

Seems like this needs a bit more discussion and a consensus. Punting.

#6 @SergeyBiryukov
3 years ago

#29599 was marked as a duplicate.

#8 @chriscct7
2 years ago

Patch still good but continues to need consensus

#9 @SergeyBiryukov
15 months ago

Leaving a note here that apparently the fix for #11694 was incomplete.

It introduced a sanity check for posts that use the <!--nextpage--> tag, but those that don't use it are still affected: https://make.wordpress.org/core/2016/09/15/media-weekly-update-sept-9/12345/

Last edited 15 months ago by SergeyBiryukov (previous) (diff)

#10 @dd32
12 months ago

#39183 was marked as a duplicate.

#11 @SergeyBiryukov
12 months ago

  • Keywords needs-unit-tests added
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#12 @SergeyBiryukov
10 months ago

#39899 was marked as a duplicate.

#13 @henry.wright
8 months ago

This patch is still good; I tested today against 4.7.4.

#14 @johnbillion
8 months ago

#29655 was marked as a duplicate.

This ticket was mentioned in Slack in #core by henrywright. View the logs.


7 months ago

#16 @henry.wright
7 months ago

You can append /page/{any number} to a page and still get the same content as http://make.wordpress.org/core/features-as-plugins/

FYI

You can also append /{any number} to a page and still get the same content.

#17 @henry.wright
7 months ago

Note that the issue I mention in #16 is not fixed by 28081.patch.

28081.patch does fix:

https://make.wordpress.org/core/features-as-plugins/page/2323/

28081.patch doesn't fix:

https://make.wordpress.org/core/features-as-plugins/2323/

#18 @henry.wright
7 months ago

I tested 28081.patch against a custom page template which uses pagination.

Tried visiting the following with the patch applied:

  • example.com/pagename/page/2/
  • example.com/pagename/page/3/
  • example.com/pagename/page/4/ etc

...all have items to show but they all redirect to example.com/pagename/

As @ocean90 suggested above, custom page templates which are using pagination are a problem.

Last edited 7 months ago by henry.wright (previous) (diff)

#19 @SergeyBiryukov
7 months ago

#40848 was marked as a duplicate.

#20 @SergeyBiryukov
4 months ago

  • Milestone changed from Future Release to 4.9

This ticket was mentioned in Slack in #forums by sergey. View the logs.


4 months ago

#22 @SergeyBiryukov
4 months ago

#41758 was marked as a duplicate.

@peterwilsoncc
3 months ago

#23 @peterwilsoncc
3 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed

In 28081.diff: original patch with unit test for canonical URL against a page with the paged query var.

#24 @dd32
2 months ago

  • Milestone changed from 4.9 to Future Release

Punting as there's been no activity in several months, and any changes to canonical generally need a lot of testing for edge cases none of us expected would ever be a thing.
@SergeyBiryukov feel free to re-milestone when you commit, if you do so this release.

#25 @SergeyBiryukov
8 weeks ago

  • Milestone changed from Future Release to 5.0

#26 @dd32
6 weeks ago

#42458 was marked as a duplicate.

#27 @chesio
10 days ago

Something I just noticed, perhaps related:

https://make.wordpress.org/core/features-as-plugins/page/123/ has <link rel="canonical" href="https://make.wordpress.org/core/features-as-plugins/" /> - duplicate content, but canonical URL is correct

vs.

https://make.wordpress.org/core/features-as-plugins/123/ has <link rel="canonical" href="https://make.wordpress.org/core/features-as-plugins/123/" /> - duplicate content with duplicate canonical URL

#28 @joostdevalk
8 days ago

  • Keywords SEO added

@chesio yeah the first example you give is not a correct URL for a paginated version of the post, whereas the second is (even though there is of course no pagination within the post), and the canonical code doesn't handle that well.

Note: See TracTickets for help on using tickets.