Nuxt和i18n:Google显示混合语言结果

问题描述

我已经使用Nuxt建立了一个站点。

该网站有2种语言:意大利语(默认)和其他所有人的英语。 我安装了nuxt-i18n并对其进行了配置,似乎一切正常(尤其是在使用devtools,html lang,rel = alternate等查看代码时。)。

但这是问题所在:当我用google(意大利语)搜索该网站时,SERP中该网站的代码段是英文。

这是我的代码:

    ['nuxt-i18n',{
      seo: false,baseUrl: 'https://www.leconturbanti.it',locales: [
        {
          name: 'Italiano',code: 'it',iso: 'it-IT',file: 'it-IT.js'
        },{
          name: 'English',code: 'en',iso: 'en-US',file: 'en-US.js'
        },],pages: {
        'contatti/index': {
          it: '/contatti',en: '/contact-us'
        },'illustrazioni-collezione/index': {
          it: '/illustrazioni-collezione',en: '/illustrations-capsule'
        }
      },langDir: 'lang/',parsePages: false,defaultLocale: 'it',lazy: true
    }]

我按照文档中的说明设置了seo: false以获得更好的性能,然后将数据合并为默认布局:

    head(){
      return{
        script:[
          {type: `text/javascript`,innerHTML: this.$t('policy.cookieId')},{src: `//cdn.iubenda.com/cs/iubenda_cs.js`,charset: `UTF-8`,type: `text/javascript`}
        ],__dangerouslyDisableSanitizers: ['script'],...this.$nuxtI18nSeo()
      }
    },

我还为$t中带有head()的每个页面设置了元标记。例如,在家里:

    head(){
      return{
        title: this.$t('seo.home.title'),meta: [
          { hid: 'description',name: 'description',content: this.$t('seo.home.description')},{ hid: 'og:title',property: 'og:title',content: this.$t('seo.home.title') },{ hid: 'og:url',property: 'og:url',content: this.$t('seo.home.url') },{ hid: 'twitter:title',property: 'twitter:title',{ hid: 'og:description',property: 'og:description',content: this.$t('seo.home.description') },{ hid: 'twitter:description',property: 'twitter:description',]     
      }
    },

我不明白我做错了什么。我已经在Search Console中添加了该网站。如果您需要对其进行检查,则网址为:www.leconturbanti.it

如果您需要更多我的代码来回答,请询问。 谢谢。

解决方法

发现此问题来自nuxt-i18n本身。 问题是Google Crawler会回退到页面的英文版本,如果您使用其他语言环境作为默认语言,则这样做不是很好。 More here.

目前,在解决问题之前,我使用的解决方法是禁用自动检测语言,以避免使用detectBrowserLanguage: false进行重定向。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...