diff --git a/errors/no-document-title.md b/errors/no-document-title.md
new file mode 100644
index 0000000000000..cbb35eb7773cb
--- /dev/null
+++ b/errors/no-document-title.md
@@ -0,0 +1,9 @@
+# Title not allowed in _document.js
+
+#### Why This Error Occurred
+
+Setting `
` in `_document.js` is a bad idea, since then it's only server rendered, but we also do client routing.
+
+#### Possible Ways to Fix It
+
+Move `` to `_app.js`
diff --git a/server/document.js b/server/document.js
index c13a3cfd2f23e..b4a98f751853a 100644
--- a/server/document.js
+++ b/server/document.js
@@ -48,7 +48,7 @@ export class Head extends Component {
if(!files || files.length === 0) {
return null
}
-
+
return files.map((file) => {
// Only render .css files here
if(!/\.css$/.exec(file)) {
@@ -82,7 +82,7 @@ export class Head extends Component {
if(!files || files.length === 0) {
return null
}
-
+
return files.map((file) => {
// Only render .js files here
if(!/\.js$/.exec(file)) {
@@ -113,7 +113,12 @@ export class Head extends Component {
{this.getPreloadMainLinks()}
{this.getCssLinks()}
{styles || null}
- {this.props.children}
+ {process.env.NODE_ENV === 'development' && (React.Children.toArray(this.props.children)).map((child) => {
+ if (child.type === 'title') {
+ console.warn('Warning: shouldn\'t be used in _document.js. https://err.sh/next.js/no-document-title.md')
+ }
+ return child
+ })}
}
}
@@ -159,7 +164,7 @@ export class NextScript extends Component {
if(!files || files.length === 0) {
return null
}
-
+
return files.map((file) => {
// Only render .js files here
if(!/\.js$/.exec(file)) {
@@ -221,4 +226,4 @@ function getPagePathname (pathname) {
}
return `${pathname}.js`
-}
+}
\ No newline at end of file