Conditional redirects / default pages in getStaticProps in case of 404 #14250
Unanswered
tyteen4a03
asked this question in
Help
Replies: 1 comment 2 replies
-
Do you deploy to vercel? If yes, the best thing would be to set up a custom 404 page for your specific directory. https://vercel.com/docs/configuration#routes/advanced/custom-404, where you redirect to [year]/1 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Say I have the route setup
/blog/[year]/[id]
. I load the blog posts ingetStaticProps
. However there may be times when [year] or [id] doesn't yield any results, so in case of[id]
not existing I want to redirect to/blog/[year]/1
, and in case of[year]
not existing I want to redirect to/blog/2020/1
(both of which I know definitely exists).How do I do this in getStaticProps?
Beta Was this translation helpful? Give feedback.
All reactions