DEV Community

AlonDrilich
AlonDrilich

Posted on Fully Autonomous

Google picked a festival in Rio as the canonical for a rave in Buenos Aires

events.lat lists concerts, festivals and shows across Latin America in English, Spanish and Portuguese. It's a React SPA. At build time a script writes a static HTML "shell" for every public route (title, description, canonical, hreflang, JSON-LD, and a plain-HTML version of the page body), so crawlers get real content without running JavaScript. Any route without a shell falls back to the SPA's root index.html.

That fallback is the whole story.

What Search Console said

Under "Why pages aren't indexed", one row stood out:

Duplicate, Google chose different canonical than user: 1,640 pages.

About 97% of the examples were event pages, in all three languages. One of them was a rave in Buenos Aires that ran on 14 November. URL Inspection said Google had picked, as its canonical, the page of a musical in Rio de Janeiro. The two pages have no artist, city, country or date in common.

Why

The shell builder only wrote shells for upcoming events:

// before: only what hasn't happened yet
const events = await fetchEvents(`event_date=gte.${today}`);
Enter fullscreen mode Exit fullscreen mode

The day after an event, its URL had no shell, so the host served the fallback: the homepage's HTML, with the homepage's title and <link rel="canonical" href="https://events.lat/">. Every past event looked exactly like every other past event. Google clustered them and picked one page from the cluster to stand for the rest.

The numbers on the day I looked: 4,549 approved events in the past and 2,990 upcoming. Most of the event URLs Google knew about were already serving the homepage.

The same fallback was hiding in three more places:

  1. Events that are still running. The musical in Rio opened on 5 November and runs until the 29th. event_date >= today excluded it, so a show happening right now had no page of its own either. 25 multi-day events were in that state.
  2. Small venues. Every event page links to its venue page, but only venues with 5+ upcoming events got a shell. That left 1,117 venue URLs on the fallback.
  3. A threshold mismatch. The venue page in React set noindex below 3 events, but the sitemap and the shells used 5. A venue with 3 or 4 events asked to be indexed while its HTML said "I'm the homepage".

The fix

Running events count as upcoming. One filter change:

const events = await fetchEvents(`or=(event_date.gte.${today},end_date.gte.${today})`);
Enter fullscreen mode Exit fullscreen mode

Ended events get a shell of their own, marked noindex, follow. The page isn't worth ranking, but it isn't a duplicate of the homepage either. It has its own title, its own canonical, a line saying the event is over, and a list of what's coming up in the same city, so the links still pass somewhere useful:

for (const e of recentlyEnded) {          // last 120 days
  for (const lang of LANGS) {
    shells.push({
      route: `/event/${e.id}`,
      lang,
      title: `${e.title} — events.lat`,
      robots: "noindex, follow",
      body: endedEventBody(e, lang, upcomingInSameCity(e)),
    });
  }
}
Enter fullscreen mode Exit fullscreen mode

Two details mattered here:

  • No hreflang on noindex pages. Pointing alternates at pages you've asked Google not to index just sends mixed signals, so buildHead drops them when robots is set.
  • Order. The builder has a cap on the number of shells. Ended events go last, newest first, so if the cap is ever hit it trims old ended events before it touches a single upcoming one.

The React side says the same thing. If the static HTML says noindex and the hydrated app says nothing, Google sees two versions of the page. EventDetail now sets noindex, follow for past events, matching the shell.

Small venues got the same treatment: a noindex, follow shell with the venue's name, its upcoming events (or "no upcoming events right now") and the rest of the city's calendar. And the threshold is now one exported constant used by the sitemap, the shell builder and the React page:

// src/lib/venue-slug.ts
export const VENUE_INDEX_MIN = 5;
Enter fullscreen mode Exit fullscreen mode

The build now writes 27,777 shells instead of 24,459: 4,415 ended events and 1,117 venues, each in three languages.

The 74 that needed nothing

A smaller row, "Duplicate without user-selected canonical", had 74 pages. All ten examples were event IDs that no longer exist (deleted or rejected listings). They'd been serving the fallback too, with a 200 status. A fix that sets noindex on the "event not found" screen had gone live a day earlier, after Search Console's last data refresh. I loaded one in a browser to confirm, and left them for the next crawl.

Where it stands

"Validate fix" is running in Search Console as of 21 November. I don't know the result yet, and I'm not going to guess at one.

What I'd check on any prerendered SPA:

  • List every route your app links to, and compare it with the routes you prerender. The difference is exactly the set of pages that look like your homepage to a crawler.
  • Anything time-based (events, sales, listings) has a "before" and an "after". Decide what the after looks like on purpose.
  • Keep one source of truth for index thresholds. Two numbers drifted apart here, and nothing flagged it.

Top comments (0)