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

<title> shows unwanted comment tags in production environment #36998

Closed
1 task done
allenchuang opened this issue May 17, 2022 · 3 comments
Closed
1 task done

<title> shows unwanted comment tags in production environment #36998

allenchuang opened this issue May 17, 2022 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@allenchuang
Copy link

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 20.6.0: Tue Feb 22 21:10:41 PST 2022; root:xnu-7195.141.26~1/RELEASE_X86_64
Binaries:
Node: 14.15.1
npm: 6.14.16
Yarn: 1.22.4
pnpm: N/A
Relevant packages:
next: 12.1.4
react: 18.0.0
react-dom: 18.0.0

What browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

In deployed environment on Vercel: I see comment tags <!-- --> added in the HTML title when i place <title> inside <Head> in next/document. This doesn't seem to happen on local.

<title>My title here<!-- --></title>

I do see the warning that:

"Titles should be defined at the page-level using next/head. See: https://nextjs.org/docs/messages/no-title-in-document-head"

I have since moved the global title to _app.tsx using next/head but wondering if this is still expected behavior

here's what i have in my _document.tsx.

import Document, { Html, Head, Main, NextScript } from "next/document";

class MyDocument extends Document {
  render() {
    return (
      <Html>
        <Head>
          <title>My title here</title>
          <meta
            name="description"
            content="Random description"
          />
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}

export default MyDocument;

Expected Behavior

I should see regular title without comment tags

<title>My title here</title>

To Reproduce

Use the following in your _document.tsx

import Document, { Html, Head, Main, NextScript } from "next/document";

class MyDocument extends Document {
  render() {
    return (
      <Html>
        <Head>
          <title>My title here</title>
          <meta
            name="description"
            content="Random description"
          />
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}

export default MyDocument;
@allenchuang allenchuang added the bug Issue was opened via the bug report template. label May 17, 2022
@c0b41
Copy link
Contributor

c0b41 commented May 18, 2022

this issue already fixed #36213 update your next version to v12.1.6

OliverFlecke added a commit to OliverFlecke/finance-tools that referenced this issue May 27, 2022
OliverFlecke added a commit to OliverFlecke/finance-tools that referenced this issue May 27, 2022
* bug: Upgraded Next to fix issue with comments in production output

See vercel/next.js#36998 for details

* bug: Improved placement of logout menu

Also added listener to close the menu when a click is registered outside of the component

* refactor: Moved login menu to individual files for better seperation

* feat: Implemented logout functionality
@SukkaW
Copy link
Contributor

SukkaW commented Jun 15, 2022

Note: React 18.2.0 also includes a change to help identify the issue: facebook/react#24679
The change won't mitigate the issue for you, but it will print a warning message to your console so you could take an action.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants