Gatsby rewrites hrefs?
See original GitHub issueHi there,
we are unable to write a simple link using <a href="">
and passing query params, I do wonder if Gatsby rewrites for some reason the links strimming out the params.
We can’t use <Link> from Gatsby since these are external links.
I looked in previous issues and I can’t find much. Is this an expected behaviour?
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
gatsby-remark-rewrite-relative-links
gatsby -remark-rewrite-relative-links. Gatsby is powered by the amazing Gatsby community and Gatsby, the company. Subscribe to our newsletter. Subscribe.
Read more >[gatsby-link] Programmatically change a.href #21610 - GitHub
Is there a way to change a.href of an anchor created with Gatbsy's Link component, so that clicking the link leads to the...
Read more >Gatsby: Navigation links to top level route on subpages ...
The Link component has been rewritten by a custom Link component and the route matching of the custom Link component was not done...
Read more >gatsby-remark-rewrite-relative-links examples - CodeSandbox
Learn how to use gatsby-remark-rewrite-relative-links by viewing and forking example apps that make use of gatsby-remark-rewrite-relative-links on CodeSandbox.
Read more >gatsby-plugin-catch-links | Yarn - Package Manager
Changelog: gatsby-plugin-catch-links. All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@DSchau spot on, thanks a lot, it’s now fixed and working.
To be clear, which link is manifesting the issue? Or are all of them?
Generally - GatsbyLink should not be used for external links. It’s for internal links to other pages within your application. If you open your console, you’ll see warnings like “A page not found for <route>” because you’ve used an external link.
As far as the search params, I think that’s an issue with hydration. The search param isn’t known at build time, so you will likely want to tap into
componentDidMount
to grab the search params and update them statefully.Does that make sense?