The Gatsby docs for path prefix show I can define something like pathPrefix: "/blog"
, and indeed I tried it and it just worked. However, I'd rather not hardcode the path where the app will live. I'd like to be able to deploy the build to multiple paths and have it just work from all of them. I'm hoping there's a way I can make the build work from any arbitrary path. Is there?
You can use gatsby-link to help you with that. It functions like React-Router's Link
component, but helps you out with path prefixing. For example, if you set your pathPrefix: "/myBlog"
...
import Link from 'gatsby-link'
/* later down in the code... */
<nav>
<Link to='/about'>About The Blog</Link>
</nav>
Which would output:
<a href="/myBlog/about">About The Blog</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With