N
Nuxt2mo ago
DragonFire

HTML lang broken

I upgrade my project and its dependencies and now my HTML-Attribute is set to lang="[object Object]" I didn't change anything and I set the lang as usual in my htmlAttrs. I also use Nuxt SEO.
3 Replies
kapa.ai
kapa.ai2mo ago
Hi @DragonFire. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It seems you're experiencing an issue with the HTML lang attribute in your Nuxt project after upgrading. This is a known issue that can happen when there's a problem with how the language value is being processed. Based on the knowledge sources, this could be happening for a few reasons: 1. The value you're passing to htmlAttrs might be an object instead of a string 2. There might be a conflict in how you're setting the language attribute Here are some solutions to try: Check your useHead implementation Make sure you're properly setting the htmlAttrs in your useHead composable:
useHead({
htmlAttrs: {
lang: 'en' // Use a string value, not an object
}
})
useHead({
htmlAttrs: {
lang: 'en' // Use a string value, not an object
}
})
Verify your Nuxt config If you're setting the language in your nuxt.config.ts, make sure it's properly formatted:
export default defineNuxtConfig({
app: {
head: {
htmlAttrs: {
lang: 'en'
}
}
}
})
export default defineNuxtConfig({
app: {
head: {
htmlAttrs: {
lang: 'en'
}
}
}
})
Check for TypeScript issues If you're using TypeScript in your Vue components, make sure you have the lang="ts" attribute in your script tag:
<script setup lang="ts">
// Your TypeScript code here
</script>
<script setup lang="ts">
// Your TypeScript code here
</script>
Missing this attribute can cause unexpected behavior as mentioned in a Stack Overflow post. Consider i18n configuration If you're using i18n, make sure your configuration is in the correct file. As noted in another Stack Overflow post, some i18n configuration should be in nuxt.config.ts rather than i18n.config.ts. If none of these solutions work, you might want to check if there are any recent issues with your Nuxt version or dependencies that could be causing this problem. Let me know if any of these suggestions help resolve your issue! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@170603372519358464> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
DragonFire
DragonFireOP2mo ago
Unfortunately not helpful. My attribute is a string and I did no changes to it. And it is not typescript.

Did you find this page helpful?