<Link> components whose href points to a hash <Link href="#abc"> or external site <Link href="https://google.com/xyz"> on a dynamic routed page e.g ./pages/blog/[id].js generate a <link rel="preload" ...> to a non existent page. This doesn't happen on standard pages e.g ./pages/index.js.
This is not a bug if <Link>'s should not link to a hash or external site and can be closed.
Either way, users can check for hashes/external links before passing them. <Link> is obviously designed for client side navigation however this is more of a convenience thing for designing components that use <Link> who don't know ahead of time if the href will be an internal, hash or external link.
Steps to reproduce the behavior, please provide code snippets or a repository:
Repo: https://github.com/delbaoliveira/next-bug-hash/blob/master/pages/blog/%5Bid%5D.js
/blog/123<link rel="preload"> tags in <head> that point to /_next/static/.../pages/blog/123.js and /_next/static/.../pages/xyz.js. These cause two 404's in the console.blog/123.js is caused by
<Link href="#abc">
<a>Go to hash</a>
</Link>
xyz.js is caused by
<Link href="https://google.com/xyz">
<a>Go to external site</a>
</Link>
Next.js should not try to preload Link's that point to a hash or external site.

I don't think external links should be used with the Link component which is why there's an error when trying to pre-render them.
Hey @delbaoliveira! <Link>s shouldn't be used with external pages -- but it's weird this only happens on a dynamic page. We'll investigate this more soon.
@Timer WDYT of showing a dev-only warning when Links’ href is external? Should be a useful feedback.
That option is definitely on the plate @kachkaev!
@jbsmith731 @Timer Fair enough re: external sites. What about <Link href="#x">?
Also correction: The external site 404 also happens on regular page. This can probably be closed.
Hmm, a # probably isn't supported but I don't see why it couldn't be. Either way, we need to add console warnings for things that aren't supported as mentioned by @kachkaev.
Let's keep this open for now. 🙏
Here's another odd behavior of <Link /> with dynamic routes, not really sure if related, but just in case it has a common root cause. Maybe useful for debugging.
@ijjk fixed this with warnings in the latest canary!
Most helpful comment
Hmm, a
#probably isn't supported but I don't see why it couldn't be. Either way, we need to add console warnings for things that aren't supported as mentioned by @kachkaev.Let's keep this open for now. 🙏