Skip to content

fix(seo): allow /api/og in robots.txt so og:image is crawlable - #128

Merged
ahnafnafee merged 1 commit into
mainfrom
fix/robots-allow-api-og
Jul 30, 2026
Merged

fix(seo): allow /api/og in robots.txt so og:image is crawlable#128
ahnafnafee merged 1 commit into
mainfrom
fix/robots-allow-api-og

Conversation

@ahnafnafee

Copy link
Copy Markdown
Owner

Summary

  • Disallow: /api/ in the wildcard robots.txt record also covered /api/og, the endpoint behind every og:image meta tag. Search Console flagged the social cards as "Blocked by robots.txt" and skipped them for rich results.
  • Added an explicit Allow: /api/og carve-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.
  • Added a validate-sitemap guard so the carve-out cannot be dropped silently. CI already runs that script against the build output.

Notes

  • No added crawl cost. /api/og already responds with Cache-Control: public, max-age=31536000, immutable, so the CDN absorbs crawler hits.
  • The AI/LLM crawler records were never affected; each carries Allow: / with no disallows.
  • The Search Console example URL is on the apex domain, which the existing apex-to-www 301 in next.config.js already handles.

Test plan

  • yarn type-check
  • yarn lint
  • yarn test (66 tests, 10 files)
  • yarn build
  • yarn validate:sitemap against build output (36 URLs, 31 images)
  • yarn validate:json-ld (291 blocks across 85 files)
  • yarn validate:icons
  • New guard verified both directions: exit 1 with the Allow line removed, exit 0 with it present
  • After deploy: confirm /robots.txt serves the Allow line, then hit "Validate Fix" in Search Console

Reference

Google's robots.txt spec: "crawlers use the most specific rule based on the length of the rule path." Their own example is allow: /p winning over disallow: /. Query strings are included in path matching, so /api/og?title=... matches the carve-out.

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.
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ahnafnafee-dev Building Building Preview Jul 30, 2026 1:38pm

@ahnafnafee
ahnafnafee merged commit 7e4f82d into main Jul 30, 2026
5 of 6 checks passed
@ahnafnafee
ahnafnafee deleted the fix/robots-allow-api-og branch July 30, 2026 13:40
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