rsnext/errors/no-duplicate-head.mdx
Delba de Oliveira 44d1a1cb15
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and
use App Router: https://github.com/vercel/front/pull/23459
2023-07-05 06:11:16 -07:00

41 lines
881 B
Text

---
title: No Duplicate Head
---
> Prevent duplicate usage of `<Head>` in `pages/_document.js`.
## Why This Error Occurred
More than a single instance of the `<Head />` component was used in a single custom document. This can cause unexpected behavior in your application.
## Possible Ways to Fix It
Only use a single `<Head />` component in your custom document in `pages/_document.js`.
```jsx filename="pages/_document.js"
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
static async getInitialProps(ctx) {
//...
}
render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument
```
## Useful Links
- [Custom Document](/docs/pages/building-your-application/routing/custom-document)