Nuxt2 displays wrong meta tags when the page is deleted
Hi everyone!
Nuxt2 returns the meta data of the last searched for page when I try to send a page that was deleted, the behaviour is very weird and I have been debugging it all day but with no hope
I have two main components one is the welcome component and this component does the fetching as in here
3 Replies
Hi @Alaa. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the knowledge sources provided do not contain information specific to Nuxt 2's behavior regarding meta tags when a page is deleted or not found. The available documentation and examples focus on Nuxt 3's meta tag management, dynamic updates, and SSR/CSR handling, but do not address this particular issue in Nuxt 2.
If you are experiencing meta tags from a previous page persisting after a page is deleted or not found, it may be related to how meta tags are managed or cached in Nuxt 2, but there is no explicit guidance or troubleshooting for this scenario in the sources above. For more accurate help, you may want to consult the official Nuxt 2 documentation or community forums.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@1323398996563202101> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
and I have the head component as this
And I also have this bit of code in my template
I have a feeling that the issue is with the
<client-only>
tag especially with my error component looking like this
To Summarize:
I'm stuck on this Nuxt 2 issue: when a user visits a non-existent profile URL, I throw an error in the fetch()
method. This correctly triggers my custom error component, but the meta tags in the <head>
(like title, description, og tags) remain from the last successful page and do not update or clear.
Here’s what I have:
The page fetches profile data in async fetch() and sets up metadata in head().
If the fetch fails, I throw a formatted error which renders a custom <error-component />.
This is all wrapped inside <client-only>, including the error component being wrapped inside it too.
I'm suspicious that head() isn't being recalculated on error, or maybe client-only is preventing it somehow?
Has anyone run into this before? What's the best way to force a proper head/meta reset when a page results in a 404 or fetch error?
Thanks in advance 🙏