nextjs - ✅(Solved) Fix Omit type attribute when types key is empty string [1 pull requests, 1 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#86080Fetched 2026-04-08 02:12:40
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Assignees
Timeline (top)
assigned ×1cross-referenced ×1issue_type_added ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #86087: fix: omit type attribute when types key is empty string

Description (problem / solution / changelog)

What?

Omits type attribute from link rel='alternate' tags when types key is an empty string. Which is a valid arguement.

Why?

When no type is required it omits the type attribute and cleans up the HTML.

How?

Only include type if it's truthy. Docs updated, passing tests included and minor code change applied.

Fixes #86080

Changed files

  • docs/01-app/03-api-reference/04-functions/generate-metadata.mdx (modified, +5/-0)
  • packages/next/src/lib/metadata/generate/alternate.tsx (modified, +5/-1)
  • test/e2e/app-dir/metadata/app/alternates/page.tsx (modified, +1/-0)
  • test/e2e/app-dir/metadata/metadata.test.ts (modified, +12/-0)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
Binaries:
  Node: 23.10.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 9.11.0
Relevant Packages:
  next: 13.5.4
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 4.9.5
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/alan-ws/type-attribute-not-omitted-when-types-key-is-empty-string

To Reproduce

  1. clone repo
  2. start app in local
  3. open chrome dev tools
  4. review elements in head
  5. note that <link> tag with rel="alternate" has an empty type

Current vs. Expected behavior

CURRENT: <link> tag with rel="alternate" has an empty type EXPECTED: <link> tag with rel="alternate" contains all props but the empty type is omitted

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
Binaries:
  Node: 23.10.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 9.11.0
Relevant Packages:
  next: 13.5.4
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 4.9.5
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)

next dev (local), Vercel (Deployed)

Additional context

No response

extent analysis

TL;DR

The issue can likely be fixed by modifying the code that generates the <link> tag to omit the type attribute when its value is an empty string.

Guidance

  • Review the code that generates the <link> tag with rel="alternate" and check how the type attribute is being set.
  • Verify that the code is correctly handling the case where the type value is an empty string.
  • Check the Next.js documentation to see if there are any configuration options or APIs that can help omit the type attribute in this case.
  • Test the fix by running the app locally and inspecting the <link> tag in the Chrome DevTools to ensure the type attribute is omitted.

Example

No code snippet can be provided without more information about the specific code that generates the <link> tag.

Notes

The fix may depend on the specific implementation of the code that generates the <link> tag, so additional information about the code may be needed to provide a more detailed solution.

Recommendation

Apply a workaround by modifying the code that generates the <link> tag to omit the type attribute when its value is an empty string, as this is a more targeted solution than upgrading to a potentially non-existent fixed version.

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 - ✅(Solved) Fix Omit type attribute when types key is empty string [1 pull requests, 1 participants]