vite icon indicating copy to clipboard operation
vite copied to clipboard

Some pages are displayed twice in search results (with and without `.html`)

Open HugoImaios opened this issue 6 months ago • 4 comments

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)

HugoImaios avatar Dec 13 '23 16:12 HugoImaios

Can you provide the source code of where the error is occurring so I can see if I can fix it.

Soumik29 avatar Dec 17 '23 19:12 Soumik29

It's not linked to any particular code from vite library, it's an issue concerning its documentation website

HugoImaios avatar Dec 18 '23 09:12 HugoImaios

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.

bluwy avatar Dec 22 '23 08:12 bluwy

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

HugoImaios avatar Dec 22 '23 09:12 HugoImaios

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

sapphi-red avatar Dec 30 '23 13:12 sapphi-red

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 avatar Jan 02 '24 09:01 HugoImaios

@HugoImaios I would appreciate it if you could open a pull request. 👍

sapphi-red avatar Jan 02 '24 12:01 sapphi-red