In the frontmatter of your post you can specify legacy redirects.
---
title: foo
date: 2012-11-10
path: bar
redirects:
- /posts/2012/11/10/foo
- /other/thing
---
# ...
Then when creating pages you can look for redirects
in frontmatter and programmatically create them.
if (node.frontmatter.redirects) {
node.frontmatter.redirects.forEach(fromPath => {
createRedirect({
fromPath,
toPath: path,
redirectInBrowser: true,
isPermanent: true
})
})
}
You can then add gatsby-plugin-meta-redirect
and redirects will happen automagically.