Gli URL hash sono un problema SIGNIFICATIVO:
Come i crawler vedono gli URL hash:
- Il tuo URL:
example.com/#/products/shoes - Cosa vede il crawler:
example.com/ - Tutti gli URL hash = stessa pagina per i crawler
La soluzione - usare History API:
// Prima (routing hash)
<Route path="/#/products/:id" />
// Dopo (history browser)
<Route path="/products/:id" />
// Configurare React Router
<BrowserRouter>
<Routes>
<Route path="/products/:id" element={<Product />} />
</Routes>
</BrowserRouter>
Configurazione server necessaria:
# nginx - serve index.html per tutte le route
location / {
try_files $uri $uri/ /index.html;
}
Priorità: In realtà questo è ancora più importante del prerendering. Gli URL hash fanno sì che i crawler non distinguano letteralmente le tue pagine.
Correggi prima gli URL, poi implementa il prerendering.