Skip to content

Is it ever a good idea to add children to next/document's Head? #13408

Answered by lfades
TyMick asked this question in Help
Discussion options

You must be logged in to vote

next/head is dynamic, you can use it multiple times, update it, remove it, and your head tag will reflect those changes.

_document.js is only rendered once, in the server, and for your entire page, this is the one that generates the initial html tag that will be used for your page and it's not a place to save any tags that rely on dynamic data, or that only apply for some pages. A good use case for this one is for example to add a custom favicon link, or google analytics, something that you know only needs to be added once and has to be always there.

_app.js is similar in the way that it's also applied globally, but it does get rendered again every time you switch the current page, so it'…

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
11 replies
@willemmulder
Comment options

@TyMick
Comment options

@willemmulder
Comment options

@TyMick
Comment options

@willemmulder
Comment options

Answer selected by TyMick
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants