Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _document for shared <head> content #56

Open
oliverjam opened this issue Nov 5, 2021 · 0 comments
Open

Use _document for shared <head> content #56

oliverjam opened this issue Nov 5, 2021 · 0 comments

Comments

@oliverjam
Copy link

oliverjam commented Nov 5, 2021

week6-EMJA/pages/buy.js

Lines 10 to 21 in 9faafaa

<Head>
<title>Thank You 💕</title>
<meta name="description" content="" />
<link rel="icon" href="/favicon.ico" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Zen+Kurenaido&display=swap"
rel="stylesheet"
/>
</Head>

You're repeating yourself quite a bit on each page to ensure they all have the right fonts, favicon etc in the <head>. Next lets you customise the "surrounding HTML" (i.e. the bit outside of the main React app) by creating a pages/_document.js(just like your pages/_app.js).

You can put the stuff that's shared across all pages in here, and reserve <Head> usage for things unique to each page (like the title)

https://nextjs.org/docs/advanced-features/custom-document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant