vite
vite copied to clipboard
Some pages are displayed twice in search results (with and without `.html`)
Documentation is
- [ ] Missing
- [ ] Outdated
- [X] Confusing
- [ ] Not sure?
Explain in Detail
For some reason (seo?) that is not questioned here, documentation pages are indexed both as /path and /path.html It's quite transparent when navigating, but when searching, it causes some results to appear twice. For example, when searching the string "Babel", we get in the "Guide & APIs" section of the results, these 4 results : a) https://vitejs.dev/guide/performance.html#use-lesser-or-native-tooling b) https://vitejs.dev/guide/performance#use-lesser-or-native-tooling c) https://vitejs.dev/guide/philosophy.html#a-pragmatic-approach-to-performance d) https://vitejs.dev/guide/philosophy#a-pragmatic-approach-to-performance
and as you can see, except the ".html" part of the url a) duplicates b), and so does c) with d)
Your Suggestion for Changes
before any "unique" operation is applied, strip out the .html artificial extension when processing search result (because I guess adding those artificial ".html" was for a good reason)
Reproduction
https://vitejs.dev/guide/
Steps to reproduce
- press Ctrl + K
- type "Babel"
- scroll to "Guide & APIs" results section
- see duplicated items (preview are the same and their page have the same content)
Can you provide the source code of where the error is occurring so I can see if I can fix it.
It's not linked to any particular code from vite library, it's an issue concerning its documentation website
The Vite site does enable Netlify's Pretty URL feature, but it seems like it doesn't redirect to the prettier URL, it only enables "understanding" how to fallback for pretty URLs. I'm not sure if there's anything we can do without changing the hosting platform, unless we manually configure redirects.
The Vite site does enable Netlify's Pretty URL feature, but it seems like it doesn't redirect to the prettier URL, it only enables "understanding" how to fallback for pretty URLs. I'm not sure if there's anything we can do without changing the hosting platform, unless we manually configure redirects.
Oh ok! For what I see and understand, redirects are OK. At least, both URLs work. The problem might come from Algolia which should not list both URLs
Adding <link rel="canonical" href="url without extension" />
to each page might work. Algolia seems to support this.
https://www.algolia.com/doc/guides/building-search-ui/resources/seo/js/#you-use-canonical-urls-to-indicate-primary-content
Adding
<link rel="canonical" href="url without extension" />
to each page might work. Algolia seems to support this. https://www.algolia.com/doc/guides/building-search-ui/resources/seo/js/#you-use-canonical-urls-to-indicate-primary-content
would you like me to open a PR with that or are you still gathering information ?
@HugoImaios I would appreciate it if you could open a pull request. 👍