DEV Community

Cloveode Technologies
Cloveode Technologies

Posted on

How we made 78 jewelry products indexable by moving off hash routing to Next.js

A client came to us with a beautiful fine-jewelry storefront that had one fatal
flaw for a business that lives on organic search: none of its products could
rank on Google.

The site was an older single-page app that used hash routing. Every product
lived at a URL like:

/jewelry#product/210-104

It looked fine to a human. To a search engine, it was a problem.

Why hash URLs kill SEO

Everything after the # in a URL is a fragment — it's handled entirely in
the browser and is never sent to the server. Googlebot sees one page
(/jewelry) and all 78 products collapse into it. There are no distinct,
crawlable URLs to index, no per-product titles, no per-product metadata.

So the catalogue was effectively invisible. The fix wasn't "more SEO plugins" —
it was giving every product a real, server-rendered URL.

We rebuilt the storefront on Next.js (App Router). Here's the playbook we
used, which applies to any catalog-style site stuck on client-side routing.

1. Give every product a static route

With the App Router, a dynamic segment plus generateStaticParams pre-renders a
real HTML page for every product at build time:


tsx
// app/jewelry/[category]/[slug]/page.tsx
import { getProducts, getProduct } from "@/lib/catalog";

export function generateStaticParams() {
  return getProducts().map((p) => ({
    category: p.category,
    slug: p.slug,
  }));
}

export default async function ProductPage({ params }) {
  const { category, slug } = await params;
  const product = getProduct(category, slug);
  // ...render the product
}

Now /jewelry/rings/solitaire-210-104 is a genuine URL Google can crawl and
index — mirroring the store's real taxonomy (category → subcategory → product).

2. Unique metadata + a canonical tag per page

Each page needs its own title, description and canonical URL. generateMetadata
runs per route:

export async function generateMetadata({ params }) {
  const { category, slug } = await params;
  const product = getProduct(category, slug);

  return {
    title: `${product.name} | Davidas`,
    description: product.summary,
    alternates: { canonical: `/jewelry/${category}/${slug}` },
    openGraph: { title: product.name, images: [product.image] },
  };
}

The canonical tag matters more than people think: it tells Google this is the
one true URL for the content, which prevents duplicate-content dilution.

3. Add Product structured data (JSON-LD)

This is what unlocks rich results — price, availability and ratings right in the
search listing. Drop a JSON-LD script into the page:

export default async function ProductPage({ params }) {
  const product = getProduct(/* ... */);

  const jsonLd = {
    "@context": "https://schema.org",
    "@type": "Product",
    name: product.name,
    image: product.image,
    description: product.summary,
    offers: {
      "@type": "Offer",
      price: product.price,
      priceCurrency: "USD",
      availability: "https://schema.org/InStock",
    },
  };

  return (
    <>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
      />
      {/* ...product UI */}
    </>
  );
}

4. Auto-generate the sitemap

Don't hand-maintain a sitemap for a catalog that changes. Generate it from the
same data source:

// app/sitemap.ts
import { getProducts } from "@/lib/catalog";

export default function sitemap() {
  return getProducts().map((p) => ({
    url: `https://example.com/jewelry/${p.category}/${p.slug}`,
    lastModified: p.updatedAt,
  }));
}

Next.js serves this at /sitemap.xml automatically. Submit it in Google Search
Console and let Google discover all 78 pages at once.

5. Preserve every legacy URL

The one step people skip — and then watch their rankings vanish. Any inbound
links or cached URLs from the old site must redirect, not 404. Map the old
patterns to the new ones:

// next.config.ts
async redirects() {
  return [
    { source: "/jewelry", destination: "/jewelry/all", permanent: true },
    // map legacy product ids → new slugs
  ];
}

A 301 passes the existing link equity to the new URL. Skipping this throws away
whatever authority the old pages had.

The result

The catalogue went from one indexable page to 78+, each with its own title,
canonical, structured data and a clean taxonomy URL — plus an auto-generated
sitemap and preserved legacy links so nothing was lost in the move. We also
ported the old PHP contact forms to serverless functions so the whole thing runs
without a legacy backend.

Takeaways

- Hash routing (#) and SEO don't mix — fragments never reach the server.
- Static routes via generateStaticParams give crawlers real pages.
- Per-page generateMetadata (title + canonical) is non-negotiable.
- JSON-LD Product schema unlocks rich results.
- Always 301 your old URLs or you lose your existing rankings.

---

We're Cloveode, a software studio that builds fast,
SEO-friendly websites, e-commerce stores and custom software. This was our
rebuild of the Davidas jewelry storefront.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)