diff --git a/packages/@vuepress/theme-default/src/client/components/NavbarItems.vue b/packages/@vuepress/theme-default/src/client/components/NavbarItems.vue index 483a1b9d2e..58c4307aae 100644 --- a/packages/@vuepress/theme-default/src/client/components/NavbarItems.vue +++ b/packages/@vuepress/theme-default/src/client/components/NavbarItems.vue @@ -27,6 +27,7 @@ const useNavbarSelectLanguage = (): ComputedRef => { } const currentPath = router.currentRoute.value.path const currentFullPath = router.currentRoute.value.fullPath + const currentHash = router.currentRoute.value.hash const languageDropdown: ResolvedNavbarItem = { text: themeLocale.value.selectLanguageText ?? 'unknown language', @@ -60,7 +61,8 @@ const useNavbarSelectLanguage = (): ComputedRef => { if ( router.getRoutes().some((item) => item.path === targetLocalePage) ) { - link = targetLocalePage + // try to keep current hash across languages + link = `${targetLocalePage}${currentHash}` } else { link = targetThemeLocale.home ?? targetLocalePath }