nextjs - 💡(How to fix) Fix Metadata descriptions containing Windows carriage returns result in duplicate <meta> tags [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#93087Fetched 2026-04-22 07:42:58
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Root Cause

It should say 1. It says 2 instead because the Windows carriage return has been stripped in the built version of the HTML but not in the data that the page is hydrated with. This causes Next to re-add the description during hydration, leading to a duplicate tag albeit with slightly different content due to the presence of the Windows carriage return in the second one.

Fix Action

Fix / Workaround

A workaround is to run output from generateMetadata though replace(/\r/g, '') to strip out the Windows carriage returns.

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:31:56 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 24.12.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.32.1
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/henrycatalinismith/carriage-return-duplicate-description-bug-demo

To Reproduce

  1. Build the demo app
  2. Run it
  3. Load the front page at http://localhost:3000
  4. Run document.querySelectorAll('meta[name="description"]').length in the console

Current vs. Expected behavior

It should say 1. It says 2 instead because the Windows carriage return has been stripped in the built version of the HTML but not in the data that the page is hydrated with. This causes Next to re-add the description during hydration, leading to a duplicate tag albeit with slightly different content due to the presence of the Windows carriage return in the second one.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:31:56 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 24.12.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.32.1
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Metadata

Which stage(s) are affected? (Select all that apply)

Other (Deployed), Vercel (Deployed)

Additional context

A workaround is to run output from generateMetadata though replace(/\r/g, '') to strip out the Windows carriage returns.

extent analysis

TL;DR

Strip Windows carriage returns from metadata to prevent duplicate description tags.

Guidance

  • Verify the issue by checking the length of document.querySelectorAll('meta[name="description"]') in the browser console and inspecting the HTML for duplicate tags.
  • Apply the suggested workaround by running the output from generateMetadata through replace(/\r/g, '') to remove Windows carriage returns.
  • Check the Next.js configuration and metadata generation code to ensure that the workaround is applied consistently.
  • Consider updating the code that generates metadata to handle Windows carriage returns correctly, rather than relying on a workaround.

Example

const metadata = generateMetadata();
const cleanedMetadata = metadata.replace(/\r/g, '');
// Use cleanedMetadata to generate the HTML

Notes

This workaround assumes that the Windows carriage returns are the only difference between the duplicate tags. If there are other differences, a more sophisticated solution may be needed.

Recommendation

Apply the workaround by stripping Windows carriage returns from the metadata using replace(/\r/g, ''), as this is a simple and effective solution to the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Metadata descriptions containing Windows carriage returns result in duplicate <meta> tags [1 comments, 2 participants]