fix(seo): allow /api/og in robots.txt so og:image is crawlable - #128
Merged
Conversation
The wildcard record disallowed all of /api/, which also covered /api/og, the endpoint that renders every og:image meta tag. Search Console reported the social cards as "Blocked by robots.txt" and skipped them for rich results. Carve /api/og out with an explicit Allow. Google and Bing resolve conflicting rules by longest matching path, so the 7-character Allow wins over the 5-character Disallow while the rest of /api/ stays blocked. Add a validate-sitemap guard so the carve-out cannot be dropped silently. CI already runs that script against the build output.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Disallow: /api/in the wildcard robots.txt record also covered/api/og, the endpoint behind everyog:imagemeta tag. Search Console flagged the social cards as "Blocked by robots.txt" and skipped them for rich results.Allow: /api/ogcarve-out. Google and Bing resolve conflicting rules by longest matching path, so the 7-character Allow overrides the 5-character Disallow while the rest of/api/stays blocked.validate-sitemapguard so the carve-out cannot be dropped silently. CI already runs that script against the build output.Notes
/api/ogalready responds withCache-Control: public, max-age=31536000, immutable, so the CDN absorbs crawler hits.Allow: /with no disallows.next.config.jsalready handles.Test plan
yarn type-checkyarn lintyarn test(66 tests, 10 files)yarn buildyarn validate:sitemapagainst build output (36 URLs, 31 images)yarn validate:json-ld(291 blocks across 85 files)yarn validate:icons/robots.txtserves the Allow line, then hit "Validate Fix" in Search ConsoleReference
Google's robots.txt spec: "crawlers use the most specific rule based on the length of the rule path." Their own example is
allow: /pwinning overdisallow: /. Query strings are included in path matching, so/api/og?title=...matches the carve-out.