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

Dynamic blog post missing doesn't return 404 but returns under construction #757

Closed
Romstar opened this issue Nov 6, 2023 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@Romstar
Copy link
Contributor

Romstar commented Nov 6, 2023

Describe the bug
Whenever you navigate to a route that a blog post doesn't exist, i.e. http://localhost:3000/blog/does-not-exist then you'll receive a 200 with an under construction page. It should return a 404 since it doesn't exist otherwise Google will continue to index the page.

Solution:
https://nextjs.org/docs/app/api-reference/functions/not-found

Simply import notFound from next/navigation and return that instead of the construction react component.

import { notFound } from 'next/navigation'
if (postIndex === -1) {
    return notFound()
  }
@Romstar Romstar added the bug Something isn't working label Nov 6, 2023
@timlrx timlrx closed this as completed in 06338b3 Nov 6, 2023
timlrx added a commit that referenced this issue Nov 6, 2023
Closes #757.  Added return notFound() to app/blog/[...slug]/page.tsx …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant