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

Missing metadata on 404 page after invoking notFound() #77512

Open
alyustik opened this issue Mar 25, 2025 · 1 comment
Open

Missing metadata on 404 page after invoking notFound() #77512

alyustik opened this issue Mar 25, 2025 · 1 comment
Labels
Metadata Related to Next.js' Metadata API. Not Found Related to the not-found.tsx file or the notFound() function.

Comments

@alyustik
Copy link

alyustik commented Mar 25, 2025

Link to the code that reproduces this issue

https://github.com/alyustik/nextjs-notfound-regression

To Reproduce

  1. Start an application in any mode (e.g. npm run dev)
  2. Navigate to non-existing page (e.g. http://localhost:3000/non-existing-page)

Current vs. Expected behavior

Current: global metadata, that was defined in root layout is missing on the non-existing page
Expected: global metadata preserves on non-existing page

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 64662
  Available CPU cores: 16
Binaries:
  Node: 22.5.1
  npm: 10.8.2
  Yarn: N/A
  pnpm: 10.5.2
Relevant Packages:
  next: 15.3.0-canary.22 // Latest available version is detected (15.3.0-canary.22).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

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

Not Found, Metadata

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

next dev (local), next build (local), next start (local)

Additional context

If it helps, that only happens on pages, where notFound() was invoked.
So if I would create directories like

  • app/about/page.tsx
  • app/articles/[slug]/page.tsx

And then I navigate to /non-existing-page - meta would work.
But if I navigate to /articles/non-existing-page - meta wouldn't work.

Happens with both generateMetadata() and metadata object.

I also tried to add metadata on not-found.tsx but it was ignored.

Issue can be reproduced starting from 15.2.0

@github-actions github-actions bot added Metadata Related to Next.js' Metadata API. Not Found Related to the not-found.tsx file or the notFound() function. labels Mar 25, 2025
@ShiftaDeband
Copy link

I can confirm that this doesn't appear to be an issue on 15.1.7. Seems to break, as noted on 15.2.0 and higher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Metadata Related to Next.js' Metadata API. Not Found Related to the not-found.tsx file or the notFound() function.
Projects
None yet
Development

No branches or pull requests

2 participants