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

Metadata not working for not found page #52636

Closed
1 task done
mehmetext opened this issue Jul 13, 2023 · 5 comments · Fixed by #52678
Closed
1 task done

Metadata not working for not found page #52636

mehmetext opened this issue Jul 13, 2023 · 5 comments · Fixed by #52678
Assignees
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Metadata Related to Next.js' Metadata API.

Comments

@mehmetext
Copy link

mehmetext commented Jul 13, 2023

Verify canary release

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

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:21:34 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8112
    Binaries:
      Node: 19.4.0
      npm: 9.4.2
      Yarn: 1.22.19
      pnpm: 8.6.5
    Relevant Packages:
      next: 13.4.10-canary.6
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.2
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

App Router, Metadata (metadata, generateMetadata, next/head)

Link to the code that reproduces this issue or a replay of the bug

npx create-next-app -e reproduction-template

To Reproduce

.

Describe the Bug

I want to add metada to not-found page but it doesn't work.
Ekran Resmi 2023-07-13 14 23 05

Ekran Resmi 2023-07-13 14 23 18 Ekran Resmi 2023-07-13 14 23 28

So, how can I add metadata to not-found.tsx?

Expected Behavior

.

Which browser are you using? (if relevant)

Google Chrome

How are you deploying your application? (if relevant)

Vercel

NEXT-1446

@mehmetext mehmetext added the bug Issue was opened via the bug report template. label Jul 13, 2023
@nicksan222
Copy link

Why would you want to do that?

@darshanjain-entrepreneur
Copy link
Contributor

here only page.tsx works

@emondpph
Copy link

Yeah I had the same issue, we should be able to add a title tag even if it's a 404 page

@mehmetext
Copy link
Author

Why would you want to do that?

Because I want to show a title for the user :) I think that it's a user experience. Also, there is a title in default 404 not found page. I want to customize it.

@huozhi huozhi self-assigned this Jul 14, 2023
@huozhi huozhi added Metadata Related to Next.js' Metadata API. linear: next Confirmed issue that is tracked by the Next.js team. labels Jul 14, 2023
@kodiakhq kodiakhq bot closed this as completed in #52678 Jul 14, 2023
kodiakhq bot pushed a commit that referenced this issue Jul 14, 2023
### What?

Support metadata exports for `not-found.js` conventions

### Why?

We want to define metadata such as title or description basic properties for error pages, including 404 and 500 which referrs to `error.js` and `not-found.js` convention. See more requests in #45620 

Did some research around metadata support for not-found and error convention. It's possible to support in `not-found.js` when it's server components as currently metadata is only available but for `error.js` it has to be client components for now so it's hard to support it for now as it's a boundary.

### How?

We determine the convention if we're going to render is page or `not-found` boundary then we traverse the loader tree based on the convention type. One special case is for redirection the temporary metadata is not generated yet, we leave it as default now.

Fixes #52636
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. 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 Aug 14, 2023
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. linear: next Confirmed issue that is tracked by the Next.js team. locked Metadata Related to Next.js' Metadata API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants