How to Gatsby Link for ‘mailto’?

I’m making a blog with gatsby but, the Link doesn’t work for mailto

Hhere is my codes. It brings me to http://localhost:8000/mailto:[email protected]
I want to use this Link for external.

<Link to='mailto:[email protected]'></Link>

Answer

Gatsby’s <Link> component extends from the @reach/router (from React) and it’s intended to use only for internal navigation. From Gatsby’s documentation:

The Gatsby <Link /> component is for linking between pages within your site. For external links to pages not handled by your Gatsby site, use the regular HTML <a> tag.

In your case, since you’re not using any kind of internal navigation, you should use a regular <a> tag, you can’t use the <Link> component. Use:

<a href='mailto:[email protected]'>Your text</a>

Leave a Reply

Your email address will not be published. Required fields are marked *