For some pages, I want to to change the URL path in the router to not map directly to the path on the filesystem.
For example: a blog post in a file "blog/2015-01-01-post-title" should have a path "blog/post-title".
Where can I hook into the route building process to change that?
Ok, seems like Gatsby automatically rewrites the path if the page has a metadata field "path".
This should really be documented somewhere!
You can also programatically rewrite paths by exporting a rewritePath
in gatsby-node.js. Also not documented yet :-
See my blog for an example https://github.com/KyleAMathews/blog/blob/master/gatsby-node.js
Would be really cool if some documentation would be added for rewritePath
at some point!
Btw, your blog no longer seems to be using rewritePath
. Maybe remove the link...
Most helpful comment
Would be really cool if some documentation would be added for
rewritePath
at some point!Btw, your blog no longer seems to be using
rewritePath
. Maybe remove the link...