This question already has an answer here:
I'm implementing a filtering option on my website where users can post and upvote images. The filtering options are:
trending (by default) and
The URLs are like this:
example.com/tags/sunset/← Trending images (ALL images with more than 5 upvotes)
example.com/tags/sunset/?sort=new← New images (ALL images ordered by descending date)
I'm using canonical URLs in order to avoid duplicate content. For example the two URLs above will have the same canonical URL (URL with trending content):
However I'm having a problem with the pagination canonical URLs.
There are 10 images per pages.
Let's say the
sunset tag have 25 images (1,2,3 pages):
but only 15 are trending (1,2 pages):
The canonical URL for the URL filtered with new content (all image) will be:
However this URL will return an error 404 because there are not 3 pages of trending content for the tag
What can I do to avoid this issue?