Skip to content

Fix SEO tag duplication and OG image generation on Cloudflare Workers#50

Merged
rafavalls merged 1 commit into
mainfrom
rafavalls/fix-seo-routing
May 12, 2026
Merged

Fix SEO tag duplication and OG image generation on Cloudflare Workers#50
rafavalls merged 1 commit into
mainfrom
rafavalls/fix-seo-routing

Conversation

@rafavalls
Copy link
Copy Markdown
Contributor

@rafavalls rafavalls commented May 12, 2026

Summary

Discord/Slack/etc. were showing the generic "Site Diagnostics" title and description for every share link instead of the per-diagnostic values. Root cause: the static defaults in `index.html` were duplicating with the injected dynamic tags, and crawlers pick the first occurrence.

  • Strip static `<title>`, `og:`, `twitter:`, and meta description from the HTML before injecting the dynamic block in the `/d/{token}` handler
  • Switch `og-image.tsx` asset loading from `node:fs` (fails on Cloudflare Workers) to `fetch()` from CDN — Inter fonts + resvg WASM — so `/og/{token}.png` works in both Bun dev and production
  • Delete the now-unused bundled TTF files

Test plan

  • After deploy, view source on a `/d/{token}` URL and confirm only ONE `og:title` / `og:description` exists, with the per-diagnostic values
  • Paste a share URL into the Facebook OG debugger / X card validator — preview shows the diagnostic title, summary, and rendered card image
  • Open `/og/{token}.png` directly — image renders within ~1–2s on first hit, instant on subsequent hits

🤖 Generated with Claude Code


Summary by cubic

Fixes duplicate SEO tags so link previews show the correct diagnostic title and description. Also makes OG image generation work on Cloudflare Workers by fetching fonts and WASM from a CDN.

  • Bug Fixes
    • Strip static <title>, meta description, og:*, and twitter:* tags from index.html before injecting dynamic tags in the /d/{token} handler.
    • Replace filesystem reads in og-image.tsx with CDN fetch() for Inter fonts and @resvg/resvg-wasm WASM, compatible with Bun dev and Cloudflare Workers.
    • Remove bundled Inter TTF files no longer used.

Written for commit fed0c5b. Summary will update on new commits.

The /d/{token} handler was appending dynamic <title>, og:*, twitter:*,
and description tags before </head> but leaving the static defaults from
index.html in place. Crawlers (Discord, Slack, etc.) pick the FIRST
occurrence of each tag, so they read the generic "Site Diagnostics"
defaults instead of the dynamic per-diagnostic values.

- Strip <title>, og:*, twitter:*, and meta description from the HTML
  before injecting the dynamic SEO block on /d/{token} routes
- Switch og-image asset loading from node:fs (Bun-only, fails on
  Cloudflare Workers) to fetch() from CDN, so /og/{token}.png works in
  both local dev and production

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
site-diagnostics fed0c5b May 12 2026, 04:03 AM

@rafavalls rafavalls merged commit eee45b1 into main May 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant