nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

Warn when using SEO features without configuring baseUrl #2941

Closed dargmuesli closed 3 hours ago

dargmuesli commented 5 months ago

Environment

Reproduction

https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-4wdrme?file=app.vue

Describe the bug

Starting with v8.3.1 some trailing slashes disappeared, which leads to these invalid headers when using useLocaleHead({ addSeoAttributes: true }):

image

Notice the empty hrefs, which should include / as they did before.

Additional context

No response

Logs

No response

BobbieGoede commented 4 days ago

After looking into this again, you actually need to set a baseUrl (see https://i18n.nuxtjs.org/docs/guide/seo) since relative URLs for alternate links are not considered valid (according to Google https://developers.google.com/search/docs/specialty/international/localized-versions#all-method-guidelines).

We should probably add warnings if baseUrl is unset when using addSeoAttributes and perhaps disable the tags altogether if unset (in v9, as that would be breaking)

dargmuesli commented 1 day ago

You're right! I was just setting baseUrl in the runtimeConfig for $production, which was a mistake by me. Thank you for looking into this! A warning sounds like a great idea. If you want, you can rename this issue to fit the idea of adding a warning, or close this and create a new issue of course.