Tim Starling has uploaded a new change for review. https://gerrit.wikimedia.org/r/154240
Change subject: Don't send rel=canonical to variant-neutral page ...................................................................... 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 --- M RELEASE-NOTES-1.24 M includes/DefaultSettings.php M includes/OutputPage.php 3 files changed, 19 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/40/154240/1 diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index e7ff835..e2fc2ba 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -42,12 +42,15 @@ 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. * Users must be able to edit a page to be able to delete it. +* $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 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 80b8e52..21ec2df 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2736,11 +2736,6 @@ $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 */ $wgDefaultLanguageVariant = false; diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2110393..32250af 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3235,7 +3235,7 @@ global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, $wgSitename, $wgVersion, $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, - $wgDisableLangConversion, $wgCanonicalLanguageLinks, + $wgDisableLangConversion, $wgRightsPage, $wgRightsUrl; $tags = array(); @@ -3347,25 +3347,23 @@ } # Language variants - if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) { + if ( !$wgDisableLangConversion ) { $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 -- To view, visit https://gerrit.wikimedia.org/r/154240 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic75717f6e4ac1f73aa600c2e1bdb9c60e607edb4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Tim Starling <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
