Reputation: 7198
Should I use <Head>
from next/head
and use it inside _app.js
or should I use <Head>
from next/document
and use it in _document.js
?
I'm kind of confused about when should I choose what. From what I understand _document.js
is only rendered on the server-side and _app.js
is rendered on both client-side and server-side.
Things I've learnt so far:
<title>
should not be used in _document.js's Does that mean I can just put everything <Head>
related inside _app.js
and be done with it? Or does it give any advantage to put all the other tags(except title and viewport) in _document.js
?
Upvotes: 4
Views: 3834
Reputation: 469
You can put anything related to Favicon
, preloading Fonts
, GTM
..etc in _document.js
and Viewport
meta related can be added into _app.js
. For other other meta tags like robots
, og
, twitter
, ... etc can be added in <Head>
of each page in your app.
Upvotes: 7