next.js: NextJS metadata don't work properly on parallel routes

Link to the code that reproduces this issue

https://github.com/azvyae/next-14-repro-bug

To Reproduce

  1. npm run build
  2. npm start
  3. Navigate to /parallel route
  4. Compare it to /non-parallel route

Current vs. Expected behavior

Problems

Metadata (especially) title not working properly when defined inside page.tsx/layout.tsx inside the parallel route folder (the folder with “@” in it), those problems are:

  • It won’t respects the title template defined inside the root layout metadata

  • Even though the UI rendered for each of them, the title is won’t changed

  • Currently, the metadata used would be the latest folder ordered by alphabet of the /@folder/page.tsx file if there are parallel routes implemented.

Expected/Solution

  • It should respect the title template defined in the root layout/parent layout

  • Because it would be confusing if we render two route at once (because its capability to render this way by parallel routes), would be possible if we render based on shown inside the layout logic? Like role_admin should render @admin otherwise @guest, because this only make the route rendered once, it should show one metadata only.

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Tue Nov 28 19:11:52 UTC 2023
Binaries:
  Node: 20.9.0
  npm: 10.1.0
  Yarn: N/A
  pnpm: 8.11.0
Relevant Packages:
  next: 14.0.4-canary.43
  eslint-config-next: 14.0.4-canary.43
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.2
Next.js Config:
  output: N/A

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

Metadata (metadata, generateMetadata, next/head), Routing (next/router, next/navigation, next/link)

Additional context

No response

NEXT-1811

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 27
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Experiencing this but with route groups. I think the issue is that Next.js only evaluates metadata from routes / segments that are actually used for routing / navigation, so that doesn’t include parallel routes nor route groups (any pages or layouts in the “@parallelroute” and “(groupname)” syntax, respectively).

If you define metadata in a normal, non-parallel , and non-route group layout or page (e.g. “app/category/page.tsx” as opposed to “app/@category/page.tsx”) it may be evaluated correctly

Also experiencing here.

I’m experiencing this with version 15.1.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0).

My file structure is as follows:

/dashboard
  /(overview)
    /page.tsx
  /layout.tsx

In my /dashboard/layout.tsx file I have set metadata, but that metadata is not applied to /dashboard/(overview)/page.tsx

I encounter the same issue too .

I’m experiencing the same issue on next@15.3.2. On initial render, the metadata shows in <head>, but after refreshing, it goes away. Below is my route structure:

app
├── dashboard
│   ├── @admin
│   │   ├── home
│   │   │   └── page.tsx
│   ├── @employee
│   │   └── home
│   │       └── page.tsx
│   ├── admin.layout.tsx
│   ├── employee.layout.tsx
│   └── layout.tsx

EDIT: I upgraded to 15.4.0-canary.61 and it seems to be resolved.

Updated to Canary, but still facing some issues. I have two parallel routes: @app and @landing. The problem is that the metadata from @landing is showing up on the @app page. The only workaround I’ve found is to remove the metadata from @landing.

Also, it seems like @landing doesn’t respect the title template defined in the RootLayout.

It works fine for me now since #77620 has been merged. (15.3.1-canary.12)