fix(seo): set metadataBase so OG images resolve to production#16
Merged
Conversation
The file-based opengraph-image route emitted og:image/twitter:image URLs pointing at http://localhost:3000, so social previews (WhatsApp, X, LinkedIn, Facebook) were broken on all marketing pages. Setting metadataBase resolves those relative URLs against the production origin. Also drops the hreflang language alternates: every language is served from the same URL, so per-language alternates all pointed here and signalled nothing. Destination pages with distinct de/en URLs keep their own. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the marketing pages (home,
/map,/compare,/best-time, feature pages) the file-basedopengraph-imageroute emitted:No
metadataBasewas set, so Next.js resolves relative metadata image URLs against the dev fallbackhttp://localhost:3000. Result: broken social share previews everywhere the site is shared (WhatsApp, X/Twitter, LinkedIn, Facebook) — no image, and anhttp://localhostlink.Destination pages were unaffected (they build an absolute
https://packedplaces.com/api/og/...URL by hand).Fix
metadataBase: new URL("https://packedplaces.com")in the rootgenerateMetadata, resolving OG/Twitter image URLs to the production origin site-wide.alternates.languageshreflang block. Every language is served from the same URL (locale is negotiated, not path-prefixed), so theen/de/es/fr/x-defaultentries all pointed athttps://packedplaces.comand signalled nothing to Google. Destination pages with distinct de/en URLs keep their own alternates.Verify
npx tsc --noEmitpasses.curl -s https://packedplaces.com | grep og:imageshould showhttps://packedplaces.com/opengraph-image....First of a small SEO/security cleanup sweep; separate PRs follow for canonical tags + sitemap and for security headers.