Head elements I added in layout.js and _app.js don't appear in exported HTML files. #13833
Replies: 1 comment
-
I've the same issue than you. I've a blog and I'm trying to generate dynamic twitter cards based on each post data. What I've noticed is:
So I suspect that _document Head is overwriting next/head somehow. Any solution to avoid it? I'm using v9.4.4. I've tried v9.4.5-canary.31 without success (same behavior) Also I noticed that using next/head, If I run build and start or export and executing an http-server, the headers appears but after deploy to vercel, they don't. 🤔 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Due to the memory shortage of my server, I adopt a static HTML generation strategy, in which I utilize npm run build & npm run export to create HTML results of my Next JS app and put those HTML files into my server.
However, head elements such as a title or meta don't appear in generated HTML files even if they behave normally in development mode (I assume that they won't be problematic in a regular Next JS app.)
Believe or not, when I put some of the head elements into _document.js HEAD, they appear. Nevertheless, migrating every head element into _document.js means I cannot assign open graph meta tags for individual pages and also I have to insert the title HTML element into _document.js, the act that should not be done in Next JS development.
I tried to search for any issue related to next/head along with Static HTML generation, but it seems to be minor discussion, therefore I post this to find out any solution.
Beta Was this translation helpful? Give feedback.
All reactions