Opened 5 years ago

Closed 5 years ago

#4150 closed defect (bug) (fixed)

canonical on homepage

Reported by: joostdevalk's profile joostdevalk Owned by:
Milestone: Priority: highest omg bbq
Component: General Keywords:

Description (last modified by joostdevalk)

The canonical on the homepage is broken which is causing a TON of issues in Google Search.

does not output a canonical, whereas

does. Both should output the exact same canonical. This is causing issues with Google self-selecting the canonical for the .org homepage and doing so horribly wrong in quite a few occasions, for example, see attached screenshot. Top left shows tested URL, bottom right shows Google's "Google-selected canonical".

Attachments (1)

gsc-wordpress-org.png (251.9 KB) - added by joostdevalk 5 years ago.

Download all attachments as: .zip

Change History (7)

#1 @joostdevalk
5 years ago

  • Description modified (diff)

#2 follow-up: @Otto42
5 years ago

The homepage, when retrieved with just, is actually a static page. The canonical there is hardcoded.

When URL parameters are passed to it, the static version is bypassed and the underlying WordPress instance is run, so what you're getting there is actually the homepage as generated by WordPress, using the wporg-main theme. It's largely the same, as you can see, except it's translatable, for rosetta sites which use it.

WordPress itself doesn't do canonical for front-page's, so, there's no code in there to do that. We could add that to the theme, but we would also need to make it aware of when the theme is running on other domains. We probably don't want to have a canonical pointing back at, I expect.

#3 @joostdevalk
5 years ago

You're right. But the front page is a specific template right? Because then getting the site URL and trailingslash-ing it would fix it?

#4 @Otto42
5 years ago

Probably. I would want to test that to be sure. :)

#5 @joostdevalk
5 years ago

Well, please do :D

#6 in reply to: ↑ 2 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Replying to Otto42:

WordPress itself doesn't do canonical for front-page's, so, there's no code in there to do that.

It does when a front page is set as such in Reading Settings.

Interestingly enough, Rosetta sites already did have a proper canonical URL on home page, as seen on The difference was that they actually have an empty "Home" page assigned as a static front page in Reading Settings. The meta tag is then printed by rel_canonical() function from core.

This page was missing on the main site. I've created one for the sake of consistency, and now rel_canonical() does its job as expected, no code changes needed :)

Note: See TracTickets for help on using tickets.