Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when using SEO features without configuring baseUrl #2941

Closed
dargmuesli opened this issue May 2, 2024 · 2 comments · Fixed by #3145
Closed

Warn when using SEO features without configuring baseUrl #2941

dargmuesli opened this issue May 2, 2024 · 2 comments · Fixed by #3145
Assignees
Labels
feature:seo 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing v8

Comments

@dargmuesli
Copy link
Collaborator

Environment

  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: npm@10.2.3
  • Builder: -
  • User Config: modules, devtools, i18n
  • Runtime Modules: @nuxtjs/i18n@8.3.1
  • Build Modules: -

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
Copy link
Collaborator

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 dargmuesli added 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing and removed bug 🐛 labels Sep 29, 2024
@dargmuesli
Copy link
Collaborator Author

dargmuesli commented Sep 29, 2024

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.

@BobbieGoede BobbieGoede changed the title fix: invalid urls starting in v8.3.1 Warn when using SEO features without configuring baseUrl Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:seo 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing v8
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants