vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.17k stars 2.12k forks source link

GitHub Pages results in "Hydration completed but contains mismatches" #3586

Open pandermatt opened 9 months ago

pandermatt commented 9 months ago

Describe the bug

When adding a / at the end of the URL using GH pages, the page breaks and results in a "Hydration completed but contains mismatches."

There are similar issues but no solution to this: https://github.com/vuejs/vitepress/pull/3468#issuecomment-1896430259

Reproduction

Visit https://projects.pandermatt.ch/vitepress-demo/markdown-examples/ (after refresh the page works) Expected URL: markdown-examples.html. The redirect happens, but the page is broken.

URL from external pages or old Search Engine results may include / which results in a bad UX (See Additional context)

Expected behavior

https://projects.pandermatt.ch/vitepress-demo/markdown-examples/ should return a 404 or redirect to home so that the user does not get a broken page. I don't know if this could be handled in the code? or it is really just a GH pages problem.

My workaround was, to move to Cloudflare pages

System Info

Only on GitHub Pages, see https://github.com/pandermatt/vitepress-demo

Additional context

I noticed this issue while trying to do something with ASDF (not my page, but they use vitepress) and i got redirected to https://asdf-vm.com/guide/getting-started/ from another page.

After navigating, the page still is broken until a reload happens

Validations

brc-dd commented 9 months ago

GitHub pages problem. I don't think we can do anything except maybe client side redirection. But that condition is tricky to properly detect.

pandermatt commented 9 months ago

Maybe we can add this known issue to the documentation in the GitHub hosting section?