Title change when I scroll

Hello, I've got problem with title using useHead. When I scroll into my page, the title changing to a another title of page.
7 Replies
Thomas Bnt
Thomas BntOP2y ago
My app.vue :
<template>
<div>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</div>
</template>
<script setup>
useHead({
titleTemplate: (title) => {
return title ? `${title} — Compagny` : "Compagny";
}
});
useSeoMeta({
ogType: "website",
twitterCard: "summary_large_image"
});
</script>
<template>
<div>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</div>
</template>
<script setup>
useHead({
titleTemplate: (title) => {
return title ? `${title} — Compagny` : "Compagny";
}
});
useSeoMeta({
ogType: "website",
twitterCard: "summary_large_image"
});
</script>
An example of page (each pages have useHead and useSeoMeta :
<script>
useSeoMeta({
description: "Cool desc",
canonical: "http://example.com",
});
useHead({
title: "Secondary page",
description: "Cool desc",
});
</script>
<script>
useSeoMeta({
description: "Cool desc",
canonical: "http://example.com",
});
useHead({
title: "Secondary page",
description: "Cool desc",
});
</script>
Under Nuxt 3.3.1 and without plugins. I have this issue when nuxi dev AND nuxi generate :c Issue always here :c
harlan
harlan2y ago
Would it be possible to make a reproduction? The issue isn't very clear from what you've provided
Thomas Bnt
Thomas BntOP2y ago
GitHub
GitHub - thomasbnt/reprod-err-nuxt3-seo-title
Contribute to thomasbnt/reprod-err-nuxt3-seo-title development by creating an account on GitHub.
harlan
harlan2y ago
But what's the issue? It's still not clear
Thomas Bnt
Thomas BntOP2y ago
Ooops wrong URL of the website. https://nuxt3-all-title-load-same-time.netlify.app/ I seen all pages load at the same time. https://i.thomasbnt.dev/i/y6amj.png My problem is : How I can have one title for one page without load all meta tags from others pages?
harlan
harlan2y ago
This is very strange, haven't seen this before 🤔 I would say it's related to ssr: false ah right it's because useHead is a vue composable, it needs to run inside the setup() method or you need to use <script setup>
Thomas Bnt
Thomas BntOP2y ago
Owwwh thanks ! Tagged this thread resolved with answer

Did you find this page helpful?