Closed mrleblanc101 closed 13 hours ago
Change the lang attribute to use a function to avoid caching the value, useHead
will call it:
useHead({
htmlAttrs: {
lang: () => i18nHead.value.htmlAttrs.lang, // <== THIS LINE
},
link: [...(i18nHead.value.link || [])],
meta: [...(i18nHead.value.meta || [])],
});
@userquin Thank you, will do. I see you closed as completed without linking to a commit, does this mean the documentation has been (or will be) updated ?
oh, can you send the link to the docs?
In fact, you should return the entire entry:
useHead(() => ({
htmlAttrs: {
lang: i18nHead.value.htmlAttrs.lang,
},
link: [...(i18nHead.value.link || [])],
meta: [...(i18nHead.value.meta || [])],
}));
Everywhere I could find useLocalHead
in the documentation
https://i18n.nuxtjs.org/docs/composables/use-locale-head#usage
and here: https://i18n.nuxtjs.org/docs/guide/seo#feature-details
Pr welcome 🙏
PR merged
Environment
Build Modules: -
Reproduction
https://github.com/capitalenumerique/interfaceqc
Describe the bug
I'm using the LanguageSwitcher exemple:
And I'm trying to implement the SEO tags using this in my
app.vue
:But the
lang="fr-CA"
does not update forlang="en-CA"
, but the URL and the app locale is updated. If I refresh the page, the lang attribute is correct:Additional context
No response
Logs
No response