mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## Summary Update code block language in [error pages](https://github.com/vercel/next.js/tree/canary/errors). ### Improving Documentation - [x] Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - [x] Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide Co-authored-by: Delba de Oliveira <[email protected]>
34 lines
724 B
Plaintext
34 lines
724 B
Plaintext
---
|
|
title: '`<title>` should not be used in _document.js `<Head>`'
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
Adding `<title>` in `pages/_document.js` will lead to unexpected results with `next/head` since `_document.js` is only rendered on the initial pre-render.
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
Set `<title>` in `pages/_app.js` instead:
|
|
|
|
```jsx filename="pages/_app.js"
|
|
import React from 'react'
|
|
import Head from 'next/head'
|
|
|
|
function MyApp({ Component, pageProps }) {
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>My new cool app</title>
|
|
</Head>
|
|
<Component {...pageProps} />
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default MyApp
|
|
```
|
|
|
|
## Useful Links
|
|
|
|
- [The issue this was reported in: #4596](https://github.com/vercel/next.js/issues/4596)
|