Incorrect Canonical URLs?

planetzu

Member
I was checking auto-generated canonical URLs for a thread that spans to 5 pages. This is what I found while checking the source code of the pages:

Canonical URL for Page 2:
Code:
<link rel="canonical" href="http://sitename.com/threads/topic.14/page-2" />

Canonical URL for Page 3:
Code:
<link rel="canonical" href="http://sitename.com/threads/topic.14/page-3" />

Canonical URL for Page 4:
Code:
<link rel="canonical" href="http://sitename.com/threads/topic.14/page-4" />

I could be wrong, but isn't it true that a Canocial URL is the main URL of the post? In which case, all Canonical URLs should point to "http://sitename.com/threads/topic.14/" and not to individual page URLs like http://sitename.com/threads/topic.14/page-2, page-3, page-4 etc.?
 
Thanks Mermaid, that's an excellent suggestion. But I am not sure how to include that in the forum as the article suggests that the first page should contain rel="next" and the 2nd page and other pages thereon should contain rel="prev" and rel="next".

So the rel="next" would need to be generated dynamically if the said thread were to have a 2nd page.

Do you have a PHP code that can achieve this?
 
Back
Top Bottom