diff --git a/packages/qwik-city/src/runtime/src/qwik-city-component.tsx b/packages/qwik-city/src/runtime/src/qwik-city-component.tsx index 038f73c6667..8550eb047a1 100644 --- a/packages/qwik-city/src/runtime/src/qwik-city-component.tsx +++ b/packages/qwik-city/src/runtime/src/qwik-city-component.tsx @@ -264,7 +264,14 @@ export const QwikCityProvider = component$((props) => { if (isBrowser) { // Use `location.href` because the lastDest signal is only updated on page navigates. if (type === 'link' && dest.href !== location.href) { - history.pushState(null, '', dest); + if (location.href.startsWith(dest.href.split('#')[0])) { + location.hash = dest.hash; + if (location.hash === '') { + history.pushState(null, '', dest); + } + } else { + history.pushState(null, '', dest); + } } // Always scroll on same-page popstates, #hash clicks, or links.