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

fix: Description set byuseServerSeoMeta gets overwritten by site description #389

Open
MickL opened this issue Jan 29, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@MickL
Copy link

MickL commented Jan 29, 2025

🐛 The bug

When using useServerSeoMeta, the description doesnt get set:

useServerSeoMeta({
  title: 'title mainpage',
  description: 'description mainpage',
});

Instead it is always set (overwritten?) by what is set in nuxt.config.ts site config:

  site: {
    url: 'https://nuxtseo.com',
    name: 'Some cool reproduction repo :)',
    description: 'Description from nuxt.config.ts',
  },

Result:

Image

🛠️ To reproduce

https://stackblitz.com/edit/nuxt-starter-tcq8ttrk?file=nuxt.config.ts,pages%2Findex.vue

ℹ️ Additional context

Works fine with useSeoMeta() BUT as far as I understood it is recommended to use useServerSeoMeta which treeshakes 2 kb out of the client build:

In most instances, the meta doesn't need to be reactive as robots will only scan the initial load. So we recommend using useServerSeoMeta as a performance-focused utility that will not do anything (or return a head object) on the client.

@MickL MickL added the bug Something isn't working label Jan 29, 2025
@MickL MickL changed the title fix: site description overwrites description set by useServerSeoMeta fix: Description set byuseServerSeoMeta gets overwritten by site description Jan 29, 2025
@harlan-zw
Copy link
Owner

harlan-zw commented Jan 30, 2025

Thanks for the detailed issue.

So the issue is that the SEO Utils plugin will insert your site config as low-priority head tags in both the server and client side. When you use useServer* it will only set it server side, any client side calls will overwrite it.

Unhead itself could in theory fix this by keeping track of SSR tag priorities, I may explore it as part of the v2 unjs/unhead#395. Keep in mind v2 may also deprecate useServer* composables as the DX around them is confusing and the optimization is not really worth it.

For the time being please use useSeoMeta(), as you're using Nuxt SEO it already uses the unhead treeshaking library which will convert useSeoMeta() to useHead() which you'd already be paying the bundle cost for.

Similar issue: harlan-zw/nuxt-seo-utils#32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants