-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUGFIX: Language fallback handling for canonical and alternate language links #154
base: master
Are you sure you want to change the base?
Conversation
Without this change untranslated pages have canonicals to themselves instead of their fallback node if set.
Thanks for fixing this issue! This is nevertheless a breaking change which could impact many websites to the negative.
What we are trying to handle might actually be quite an edge case... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is fine, but see my comment on use case.
I disagree that it's an edge case. Actually most projects I'm involved with which use multiple languages use fallbacks to completely different languages. Most of the time everything falls back to English and the customers want to have a full page tree in all languages as they don't know when they are able to localise everything. I also don't really see the negative SEO effect. Why should the UK version when it's not localised have its own canonical and language link? If this is really required to be defined on a per preset basis we might need additional options in the presets or in the SEO settings. |
Got it - and good to know there are many websites that will benefit (so will neos.io)! But we are introducing something that will have an effect on many websites that are using this package Flagging derivates is a main use case of hreflang. When i have a website for Austria (.at) that shares most of the content with the german version (.de) but has different products, i would want the austrian user to find austrian results (de-at). |
So you mean regarding the canonical and alternate language links the new behaviour should be behind a feature flag, which we might inverse with a major release? |
@@ -22,6 +22,7 @@ prototype(Neos.Seo:AlternateLanguageLinks) < prototype(Neos.Fusion:Component) { | |||
@if.isDefaultLocale={props.defaultLocale == item.dimensions[props.dimension][0]}/> | |||
<Neos.Seo:AlternateLanguageLink node={item.node} | |||
@if.isNotAbsent={item.state != 'absent'} | |||
@if.existsInTargetDimensions={item.node.dimensions == item.node.context.targetDimensionValues} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked the hreflang specs. We need to remove hreflang in the "unlogic fallback" case as nothing points to this version.
Actually "@if.hasNoForeignCanonical" needs to be adapted as it does have a foreign canonical
https://developers.google.com/search/docs/advanced/crawling/localized-versions?hl=en
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't fully understand what needs to be done from your description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually something like
@if.hasNoForeignCanonical = ${String.isBlank(q(this.node).property('canonicalLink'))}
@if.nodeIsTranslated = ${this.node.dimensions == this.node.context.targetDimensionValues}
... line 5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, so an additional check for the canonical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the query @if.existsInTargetDimensions={item.node.dimensions == item.node.context.targetDimensionValues}
no hreflang is output when I only adjust content on a page that has a language fallback.
We have now added the following queries in Neos.Seo:AlternateLanguageLink:
@if.hasMetaRobotsNoIndexNotSet = ${q(this.node).property('metaRobotsNoindex') || q(this.node).is('[instanceof Neos.Seo:NoindexMixin]') ? false : true} @if.hasNoForeignCanonical = ${String.isBlank(q(this.node).property('canonicalLink'))}
thanks to @regniets 😉
I'm not into SEO that much (I just know that duplicate content is bad) so I can't really vote on this change. But from my own experience I can tell that breaking changes in this package can be very harmful because they can be quite subtle. When I updated a large project recently it introduced a different set of metatags leading to a downgrade on Google. |
@Sebobo - i think a feature flag might be the best solution. |
A customer of mine required the same fix today for a project with many languages and 2 dimensions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[…] and will finish up this PR when they are happy with it.
Any news?
indeed, got a customer project as well now that could need the fix :) |
The canonical link will now link to the original node if a dimension fallback is active.
The list of alternate language links will not contain nodes anymore if they don't exist in the target language.
Also the
lang
attribute of the html tag is now correct when a fallback is shown.All three issues can be tested by browsing to
/uk
in the Neos.Demo.lang
should been_US
, canonical should link to it to and no alternate language link for uk should exist.