我用Nuxt做了个网站。
该网站有两种语言:意大利语(默认)和其他人的英语。我安装了nuxt-i18n并配置了它,一切看起来都很好(特别是在查看devtools、html lang、rel=alternate等代码时)。
但问题是:当我用谷歌(意大利语)搜索网站时,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', 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') },
]
}
},我不明白我做错了什么。我已经在搜索控制台中添加了这个站点。如果您需要访问它进行检查,网址是:www.leconturbanti.it
如果你需要更多的我的代码来回答,只需问。谢谢。
发布于 2020-08-28 23:08:49
发现这个问题来自nuxt-i18n本身。问题是Google Crawler会退回到页面的英文版本,如果默认使用另一个区域设置,这就不好了。更多在这里。
目前,在问题解决之前,我使用的解决方法是禁用自动检测语言,以避免使用detectBrowserLanguage: false重定向。
发布于 2022-10-29 15:40:31
我的裸体头像:
head(){
return {
...this.$nuxtI18nHead({ addDirAttribute: true, addSeoAttributes: true }),
title: this.page.title,
meta: [
{
property: 'og:description',
name: 'description',
content: this.page.description
},
{
property: 'og:title',
name: 'title',
content: this.page.title
}
],
}
},我的nuxt.config.js
i18n: {
locales ,
strategy: 'prefix',//no_prefix , prefix , prefix_and_default ,prefix_except_default
vueI18nLoader: true,
defaultLocale: process.env.LOCALE_DEFAULT||'en',
langDir: '~/locales/',
vueI18n: {
silentTranslationWarn: true
},
detectBrowserLanguage: false
},https://stackoverflow.com/questions/63359724
复制相似问题