我已经使用 Nuxt 创建了一个站点。
该网站有 2 种语言:意大利语(默认)和其他所有人的英语。我安装了 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') },
]
}
},
我不明白我做错了什么。我已经在 Search Console 中添加了该网站。如需参观,网址为:www.leconturbanti.it
如果您需要更多我的代码才能回答,请询问。谢谢你。