Link-to helper to an anchor in another route

I’ve looked through this discussion about using hashes for the traditional scroll-to-anchor behavior, and it “just works” if you’re using location: 'history'. Example: if I’m on the index route, and I have a link

<a href="#chapter-one">Jump to first chapter</a>

This works great. But, is there a way to use this behavior in conjunction with a {{#link-to}} helper such that I can transition to a route and then jump to the anchor?

<a href="/about#contact">Send us a message</a>

This works, but suffers from a) relying on matching the path rather than route name, and b) reloading the app instead of just transitioning. What I need is {{#link-to "about#contact"}} or {{#link-to "about" hash="contact"}} but it seems like these don’t exist. Is there something I’m missing? Any best practices or clean workarounds?

4 Likes