LoginSignup
5
2

More than 3 years have passed since last update.

多言語サイトで自動リダイレクトを導入したらGoogleの検索結果が英語になった

Last updated at Posted at 2017-04-04

前提条件

  • 多言語サイト、日英のみ
  • ブラウザの言語設定をみて、各言語ページへリダイレクトする処理をJavaScriptでかいている

現象

Google(日本)の検索結果のタイトルとdescriptionが英語ページのものになった

解決策

UAに'googlebot'が含まれていた場合、自動リダイレクトしないようにした

// Googleクローラはリダイレクトしない
// 検索結果のdescriptionやtitleが英語ページのものになってしまうため
const userAgent = window.navigator.userAgent.toLowerCase();
if (userAgent.indexOf('googlebot') === -1) {
  /**
   リダイレクトする処理
 **/
}

参考)GoogleクローラーのUA一覧

考察

Googleクローラーは言語が英語になっていて、クロールの最中に英語サイトへリダイレクトしてしまい、
英語のサイトのタイトルとdescriptionを取得してしまっていたと思われる🙉

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2