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

generateMetadata is not called anymore if it is in page.tsx, it's called only from layout.tsx when upgrading from v14.2.7 to v14.2.8, making all the pages dynamic titles to disappear. #70717

Closed
RazvanRauta opened this issue Oct 2, 2024 · 3 comments · Fixed by #70732
Labels
bug Issue was opened via the bug report template. locked Metadata Related to Next.js' Metadata API.

Comments

@RazvanRauta
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/practical-silence-f2sz85?workspaceId=a8fd7a94-21d9-4864-97fb-6ae7e1b980d5

To Reproduce

  1. Upgrade nextjs to v14.2.8

  2. Create some pages with the following folder structure:

| [ lang ]
│   layout.tsx <-------  generateMetadata () =>   return { title: "Layout" };
│
└───( group )
|   group-layout.tsx
|
│   └───page 1
│       │   page.tsx         <-------  generateMetadata () =>   return { title: "Page 1" };
│       │   page-content.txt
|
│   └───page 2
│       │   page.tsx        <-------  generateMetadata () =>   return { title: "Page 2" };
│       │   page-content.txt

  1. The title from layout.tsx is shown, not the one from page.tsx. If the generateMetadata function is deleted from layout.tsx, no title is shown in the browser tab.

  2. Downgrade nextjs to v14.2.7 and the titles from page.tsx are back without any changes.

Current vs. Expected behavior

generateMetadata should work like before v14.2.8

Provide environment information

Operating System:
  Platform: linux
  Arch: arm64
  Version: #1 SMP Wed Jul 17 10:51:09 UTC 2024
  Available memory (MB): 7839
  Available CPU cores: 11
Binaries:
  Node: 20.17.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 9.1.0
Relevant Packages:
  next: 14.2.8 // There is a newer version (14.2.14) available, upgrade recommended! 
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
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), next build (local)

Additional context

The bug was introduced in v14.2.8.

@RazvanRauta RazvanRauta added the bug Issue was opened via the bug report template. label Oct 2, 2024
@github-actions github-actions bot added the Metadata Related to Next.js' Metadata API. label Oct 2, 2024
@samcx
Copy link
Member

samcx commented Oct 2, 2024

@RazvanRauta Thank you for submitting an issue!

I was able to confirm this issue. We will be taking a look at this!

@samcx
Copy link
Member

samcx commented Oct 2, 2024

@RazvanRauta

What's interesting is that you split up the generateMetadata and the Client Component, so Next.js was not able detect that generateMetadata was in a Client Component.

If you combine them →
CleanShot 2024-10-02 at 12 40 38@2x

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. 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 Oct 18, 2024
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. locked Metadata Related to Next.js' Metadata API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants