Don't send rel=canonical to variant-neutral page
This has been the subject of multiple complaints from Google, it apparently prevents them from properly indexing the variant-specific pages. Instead, send the variant-independent link as rel=alternate hreflang=x-default, which is recommended by Google as the preferred way of specifying "auto-redirecting homepages" in this help page: https://support.google.com/webmasters/answer/189077?hl=en Send rel=alternate links unconditionally, since that is also recommended by that help page: "each language page must identify all language versions, including itself". Remove $wgCanonicalLanguageLinks since it would be rather pointless and poorly named if it only controlled rel=alternate links. Bug: 52429 Change-Id: Ic75717f6e4ac1f73aa600c2e1bdb9c60e607edb4
This commit is contained in:
parent
277348f440
commit
91d8a51825
3 changed files with 18 additions and 22 deletions
|
|
@ -42,8 +42,8 @@ production.
|
|||
configurations are $wgDeletedDirectory and $wgHashedUploadDirectory.
|
||||
* The deprecated $wgUseCommaCount variable has been removed.
|
||||
* $wgEnableSorbs and $wgSorbsUrl have been removed.
|
||||
* The UserCryptPassword and UserComparePassword hooks are no longer called. Any extensions
|
||||
using them must be updated to use the Password Hashing API.
|
||||
* The UserCryptPassword and UserComparePassword hooks are no longer called.
|
||||
Any extensions using them must be updated to use the Password Hashing API.
|
||||
* $wgCompiledFiles has been removed.
|
||||
* $wgSortSpecialPages was removed, the listing on Special:SpecialPages is
|
||||
now always sorted.
|
||||
|
|
@ -65,6 +65,9 @@ production.
|
|||
may need to adjust your default user settings to compensate for the index change.
|
||||
* $wgDeferredUpdateList is now deprecated, you should use DeferredUpdates::addUpdate()
|
||||
instead.
|
||||
* $wgCanonicalLanguageLinks has been removed. Per Google recommendations, we
|
||||
will not send a rel=canonical pointing to a variant-neutral page, however
|
||||
we will send rel=alternate.
|
||||
|
||||
=== New features in 1.24 ===
|
||||
* Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
|
||||
|
|
|
|||
|
|
@ -2699,11 +2699,6 @@ $wgDisableLangConversion = false;
|
|||
*/
|
||||
$wgDisableTitleConversion = false;
|
||||
|
||||
/**
|
||||
* Whether to enable canonical language links in meta data.
|
||||
*/
|
||||
$wgCanonicalLanguageLinks = true;
|
||||
|
||||
/**
|
||||
* Default variant code, if false, the default will be the language code
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3336,25 +3336,23 @@ $templates
|
|||
}
|
||||
|
||||
# Language variants
|
||||
if ( !$config->get( 'DisableLangConversion' ) && $config->get( 'CanonicalLanguageLinks' ) ) {
|
||||
if ( !$config->get( 'DisableLangConversion' ) ) {
|
||||
$lang = $this->getTitle()->getPageLanguage();
|
||||
if ( $lang->hasVariants() ) {
|
||||
|
||||
$urlvar = $lang->getURLVariant();
|
||||
|
||||
if ( !$urlvar ) {
|
||||
$variants = $lang->getVariants();
|
||||
foreach ( $variants as $_v ) {
|
||||
$tags["variant-$_v"] = Html::element( 'link', array(
|
||||
'rel' => 'alternate',
|
||||
'hreflang' => wfBCP47( $_v ),
|
||||
'href' => $this->getTitle()->getLocalURL( array( 'variant' => $_v ) ) )
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$canonicalUrl = $this->getTitle()->getLocalURL();
|
||||
$variants = $lang->getVariants();
|
||||
foreach ( $variants as $_v ) {
|
||||
$tags["variant-$_v"] = Html::element( 'link', array(
|
||||
'rel' => 'alternate',
|
||||
'hreflang' => wfBCP47( $_v ),
|
||||
'href' => $this->getTitle()->getLocalURL( array( 'variant' => $_v ) ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
# x-default link per https://support.google.com/webmasters/answer/189077?hl=en
|
||||
$tags["variant-x-default"] = Html::element( 'link', array(
|
||||
'rel' => 'alternate',
|
||||
'hreflang' => 'x-default',
|
||||
'href' => $this->getTitle()->getLocalURL() ) );
|
||||
}
|
||||
|
||||
# Copyright
|
||||
|
|
|
|||
Loading…
Reference in a new issue