Skip to content

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

@RazvanRauta

Description

@RazvanRauta

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MetadataRelated to Next.js' Metadata API.bugIssue was opened via the bug report template.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions