Currently gatsby-link
doesn't work properly with external links. Instead of showing the url, it append the url with the current url, it shows: http://localhost:8000/https:/mittalyashu.now.sh
It should have redirected to https://mittalyashu.now.sh
By passing a parameter external
.
<Link external to="https://mittalyashu.now.sh">External page</Link>
Gatsby鈥榮 Link component shouldn鈥檛 be used for external links:
https://next.gatsbyjs.org/docs/gatsby-link/#use-link-only-for-internal-links
Based on the Gatsby docs linked, any external link appears to be just a simple <a>
tag with an href as usual. However in my Gatsby application, when I follow this, I can not get the external links to work. My external href's are added to localhost:8000 and I get a 404 page not found. Am I missing something here?
<a href="www.github.com/maisonm" target="_blank" rel="noopener norefferer">
<img src={Github} alt="github logo" />
</a>
Solved. Just a lazy oversight on my end, but I am leaving this here for anyone else who comes across this: you must use https:// or http:// in the href tag for an external link to work.
you must use
https://
orhttp://
in the href tag for an external link to work.
This should really be in the docs.
Edit: I created a PR to add it to the docs.
target="_blank" rel="noopener norefferer"
@maisonm Thanks for this. Just a quick note that it should be noreferrer
(small typo).
Most helpful comment
Based on the Gatsby docs linked, any external link appears to be just a simple
<a>
tag with an href as usual. However in my Gatsby application, when I follow this, I can not get the external links to work. My external href's are added to localhost:8000 and I get a 404 page not found. Am I missing something here?<a href="www.github.com/maisonm" target="_blank" rel="noopener norefferer"> <img src={Github} alt="github logo" /> </a>
Solved. Just a lazy oversight on my end, but I am leaving this here for anyone else who comes across this:
you must use https:// or http:// in the href tag for an external link to work.