【问题标题】:Nuxt and i18n: Google showing mixed language resultsNuxt 和 i18n:Google 显示混合语言结果
【发布时间】:2020-12-01 05:03:20
【问题描述】:

我已经使用 Nuxt 创建了一个网站。

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

但问题是:当我用 google(意大利语)搜索网站时,SERP 中该网站的 sn-p 是英文。

这是我的代码:

    ['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()
      }
    },

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

    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', content: this.$t('seo.home.title') },
          { hid: 'og:description', property: 'og:description', content: this.$t('seo.home.description') },
          { hid: 'twitter:description', property: 'twitter:description', content: this.$t('seo.home.description') },
        ]     
      }
    },

我不明白我做错了什么。我已经在 Search Console 中添加了该网站。如需访问查看,网址为:www.leconturbanti.it

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

【问题讨论】:

  • 这个运气好吗?遇到同样的问题..
  • 是的,我发布了一个答案。看看吧。

标签: internationalization seo nuxt.js nuxt-i18n


【解决方案1】:

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

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

【讨论】:

  • 你知道,我有点认为这是问题所在,但我不想为了解决它而弄乱 SEO 排名。感谢您的确认!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-29
  • 1970-01-01
  • 2018-12-03
  • 1970-01-01
  • 1970-01-01
  • 2016-06-26
相关资源
最近更新 更多