FAQ
Multi-language Switching Fails in Dev Mode
Problem Description
In development mode (pnpm dev), the multi-language switching feature for virtual pages (Tags, Categories, Archives) does not work properly. Specifically:
- Switching languages does not update the page content
- The page shows 404 or displays content in the default language
Root Cause
Virtual pages in VitePress are implemented through Vite plugins. In development mode, there is an interaction issue between Vite Dev Server's routing and VitePress's own routing system:
- Vite plugin hooks (
resolveId()andload()) may not be triggered at the right time in sync with VitePress's routing system in dev mode - Multi-language path prefixes (like
/zh/tags/) may not be correctly recognized inresolveIdmatching - Modifications to
siteConfig.pagesmay not take effect immediately in development mode
Temporary Solutions
- Use production mode preview: Run
pnpm buildto build, then usepnpm previewto preview the production version - multi-language switching works correctly - Avoid testing multi-language in dev mode: Complete your development in the default language first, then verify multi-language effects in production mode
Related Files
packages/theme/src/node/plugins/virtualTagPlugin.tspackages/theme/src/node/plugins/virtualCategoriesPlugin.tspackages/theme/src/node/plugins/virtualArchivesPlugin.ts
TIP
This issue only affects development mode. Production builds are not affected.
Changelog
2026-04-18 23:32
View All Changelog