2023-07-05 15:11:16 +02:00
---
title: '`<title>` should not be used in _document.js `<Head>`'
---
2018-09-28 00:24:12 +02:00
2023-07-05 15:11:16 +02:00
## Why This Error Occurred
2018-09-28 00:24:12 +02:00
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.
2023-07-05 15:11:16 +02:00
## Possible Ways to Fix It
2018-09-28 00:24:12 +02:00
2018-12-03 23:04:18 +01:00
Set `<title>` in `pages/_app.js` instead:
2018-09-28 00:24:12 +02:00
2023-07-05 15:11:16 +02:00
```js filename="pages/_app.js"
2018-09-28 00:24:12 +02:00
import React from 'react'
2020-07-07 07:43:16 +02:00
import Head from 'next/head'
2018-09-28 00:24:12 +02:00
2020-07-07 07:43:16 +02:00
function MyApp({ Component, pageProps }) {
return (
<>
<Head>
<title>My new cool app</title>
</Head>
<Component {...pageProps} />
</>
)
2018-09-28 00:24:12 +02:00
}
2020-07-07 07:43:16 +02:00
export default MyApp
2018-09-28 00:24:12 +02:00
```
2023-07-05 15:11:16 +02:00
## Useful Links
2018-09-28 00:24:12 +02:00
2020-05-27 23:51:11 +02:00
- [The issue this was reported in: #4596](https://github.com/vercel/next.js/issues/4596)