admin管理员组文章数量:1410674
Description: I'm using Nuxt 3 with useHead() to set dynamic meta tags based on locale. The meta tags appear correctly in the Elements tab (DevTools) but are missing in "View Page Source".
This suggests that the meta tags are only being set on the client-side instead of during Server-Side Rendering (SSR).
What I Have Tried:
- Ensured SSR is enabled in nuxt.config.ts:
export default defineNuxtConfig({
ssr: true,
target: 'server',
});
- Used useHead() inside watchEffect() to update meta tags dynamically:
watchEffect(() => { if (pending.value) return; useHead({ title: t('metaHomeTitle'), meta: [ name: 'description', content: t('metaHomeDescription') }, property: 'og:title', content: t('metaHomeOGTitle') }, property: 'og:description', content: t('metaHomeOGDescription') }, property: 'og:url', content: '/' }, ], }); });
- Checked if SSR is working properly by running:
`curl -A "Googlebot" -L http://localhost:3000/es`
- The output still shows an old or incorrect title.
- Cleared Nuxt cache and rebuilt the project:
`rm -rf .nuxt && npm run dev`
Expected vs. Actual Behavior:
- Expected: The updated meta tags should appear in View Page Source and be accessible for SEO & crawlers.
- Actual: Meta tags only update dynamically in DevTools, but View Page Source still shows default values.
Questions:
- Why is Nuxt not rendering the correct meta tags in SSR mode?
- Is there a proper way to force Nuxt to generate static meta tags for SEO?
- Could this issue be caused by
useHead()
being called insidewatchEffect()
instead of at the top level?
版权声明:本文标题:vuejs3 - Nuxt 3: Meta Tags Not Updating in "View Page Source" but Visible in DevTools - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744994336a2636577.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论