Following on from the conversation in #1518224: Change canonical URL handling on multilingual site, it appears to be Google's preference for there to not be a canonical URL meta tag if there are hreflang meta tags too.

Annotating pages as substantially similar content
to simplify implementation, we no longer recommend using rel=canonical.

http://googlewebmastercentral.blogspot.fr/2011/12/new-markup-for-multili...

Comments

DamienMcKenna created an issue. See original summary.

mfb’s picture

I'm curious how important this is? Does having a canonical meta tag really break anything re: search indexing?

By the way, one way to implement this is to have a blank canonical meta tag configured in the metatag settings (this seems like an ok workaround, assuming that all sites that care about metatags will install the metatag module :)

kepford’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

This patch adds checks for hreflang in meta tags and removes the canonical meta tag if a hreflang exists.

kepford’s picture

The previous patch did not check for multiple hreflang tags. This patch checks to make sure there is more than one hreflang. Also moves logic into one function.

kepford’s picture

damienmckenna’s picture

StatusFileSize
new1.34 KB

Some minor changes, mainly dropping one of the variables.

kepford’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies and works as intended.

mfb’s picture

Status: Reviewed & tested by the community » Needs work

Did some reading about this. According to http://www.rebelytics.com/hreflang-canonical/ "If you are using a canonical tag solution on your website, make sure that URLs that have a canonical tag pointing to another URL do not receive hreflang annotations. hreflang annotations are okay for URLs that point to themselves via canonical tag and for URLs that do not have canonical tags."

Also, needs tests.

kepford’s picture

Right. So the idea is that if you only have one hreflang tag you can still have a canonical tag which is what the patch does. I'll work on adding tests.

mfb’s picture

What about the suggestion that it's ok to have hreflang tags on URLs that have a canonical tag pointing at itself? It seems like what we actually need to do is remove the hreflang tags if the page has a canonical tag pointing elsewhere?

kepford’s picture

Status: Needs work » Closed (works as designed)

Ok, now I get what you are saying @mfb. This seems to be a non-issue for hreflang module to me now. Agree @DamienMcKenna? I can't reproduce a condition where the canonical tag points to another language.

mfb’s picture

From what I've seen in real-world testing, if I go to a node/[nid] page, the canonical and hreflang tags all point elsewhere (to the correct URLs using URL aliases), and I don't see why Google would be confused.