SEO Architecture, Debugging & Production Review
Production SEO is a distributed system of signals.
It spans:
route tree
content model
canonical URLs
metadata
Open Graph/Twitter
structured data
robots policy
sitemaps
redirects
Proxy
caching
CDN/reverse proxy
deployment environments
A senior engineer does not debug SEO by editing <title> until a preview looks right.
They trace the document identity through every layer.
A production SEO architectureβ
For a public content page:
CMS / database
β
public domain model
β
route resolution
β
page UI
β
metadata + canonical
β
Open Graph / Twitter
β
JSON-LD
β
sitemap membership
β
public crawler delivery
Each layer should agree on publication state and URL identity.
One public truth modelβ
Avoid independent logic such as:
page checks `publishedAt`
metadata checks `status === LIVE`
sitemap checks `deletedAt === null`
OG image checks nothing
That creates leaks and inconsistencies.
Prefer a public read model:
type PublicArticle = {
slug: string
title: string
summary: string
publishedAt: Date
updatedAt: Date
canonicalPath: string
heroImage: string | null
author: PublicAuthor
}
and one query boundary that guarantees the record is publishable.
Route identity reviewβ
For every public route, answer:
What URLs can reach this content?
Which one is canonical?
Which ones redirect?
Which are language variants?
Which query parameters change content meaning?
Which are tracking-only?
If the team cannot answer this, metadata will become inconsistent.
Content lifecycle reviewβ
Model SEO across lifecycle states:
draft
scheduled
published
updated
unpublished
slug renamed
deleted
For each state define:
- page response
- canonical
- robots policy
- sitemap membership
- social image visibility
- JSON-LD visibility
- redirect behavior
Slug renameβ
A robust rename flow:
/products/old-widget
β permanent redirect
β /products/new-widget
Then ensure:
new page canonical = new URL
sitemap contains only new URL
OG URL = new URL
JSON-LD URL = new URL
internal links use new URL
Do not keep both URLs as competing indexable documents.
Deleted contentβ
Deletion policy depends on product semantics.
Possible outcomes:
410 Gone
404 Not Found
redirect to replacement/category
Avoid keeping a deleted URL in sitemap with a canonical to a generic homepage.
That hides the real lifecycle signal.
Paginationβ
Pagination SEO needs product-specific reasoning.
For:
/blog?page=1
/blog?page=2
/blog?page=3
ask whether each page contains distinct useful content that should be discoverable.
Do not automatically canonicalize every page to page 1 if that makes deeper content effectively undiscoverable.
Faceted navigationβ
Facets can explode URL count:
/shoes?size=10&color=black&brand=acme&sort=price
Classify query dimensions:
meaningful landing facet
β potentially indexable
sort/view/tracking
β usually not separate document identity
high-cardinality combinations
β may need crawl/index restrictions
SEO architecture should align with product URL design.
Internationalizationβ
For localized content, verify:
locale URL
localized visible content
localized title/description
canonical for locale
hreflang alternates
localized OG text/image if required
sitemap alternate languages
JSON-LD language/content consistency
Do not emit hreflang for translations that do not exist.
Multi-tenant SEOβ
For tenant sites, decide whether tenants are:
private application spaces
public microsites
custom-domain public sites
subdomain public sites
marketplace listings under main domain
Each has different canonical and crawl policy.
Never let raw unvalidated host headers define public identity.
Use the trusted-host model from Phase 9.
Authenticated routesβ
SEO for authenticated product routes is usually simple:
generic safe title
noindex
no public sitemap entry
no private OG image
no private JSON-LD
The critical requirement is still access control.
Do not spend database latency personalizing metadata for a page search engines should not index.
Environment matrixβ
Review every deployment class:
| Environment | Public crawl? | Canonical host | Sitemap? | Verification? |
|---|---|---|---|---|
| Production | yes, as intended | production origin | yes | production tokens |
| Preview | normally no | production canonical or noindex policy | usually no | usually no |
| Staging | controlled | explicit staging policy | usually no | test-only if needed |
| Local | no | local | no | no |
The exact policy varies, but accidental ambiguity is dangerous.
Preview safetyβ
A preview deployment should not accidentally emit:
self-canonical preview URL
production sitemap containing preview host
production verification ownership
index,follow for unpublished content
Use explicit environment-aware policy.
Proxy interaction reviewβ
Inspect whether proxy.ts affects:
page requests
robots.txt
sitemap.xml
OG/Twitter image routes
icons
manifest
crawler user agents
locale redirects
host/tenant routing
A route can have perfect metadata code and still fail because Proxy redirects the crawler before the route runs.
HTTP status firstβ
Before debugging metadata, verify status codes.
SEO signals on a broken response are secondary.
Start with:
200 expected document
3xx intentional redirect
404/410 missing/deleted document
5xx server failure
A 200 page that says βnot foundβ is a soft-404 pattern.
Raw request debuggingβ
Use a repeatable checklist:
curl/fetch final URL
follow and record redirects
inspect response status
inspect response headers
inspect initial HTML
fetch with crawler user agent
fetch metadata assets directly
Compare browser behavior only after transport behavior is known.
Metadata streaming debuggingβ
If metadata appears in the final browser DOM but not where you expected in raw HTML:
- Determine whether
generateMetadatais request-time. - Determine whether streaming metadata is active.
- Test an HTML-limited crawler user agent.
- Check
htmlLimitedBotsconfiguration. - Inspect dependency latency.
- Confirm metadata is not being overwritten by a child/file convention.
Social preview debuggingβ
When a platform shows an old or missing card:
check page URL status
check canonical/og:url
check crawler metadata response
check image URL status/content type/size
check file-based override
check generated image cache
check platform's own preview cache
Do not rebuild the app repeatedly before checking platform caching.
Sitemap debuggingβ
When expected content is missing:
publication query
partition/generateSitemaps math
cache freshness
canonical slug
soft-delete filters
locale filter
page size/range boundary
When too many URLs appear, inspect whether filters/sort/tracking variants are being generated as canonical URLs.
Robots debuggingβ
When crawling drops unexpectedly:
robots.txt environment config
Proxy redirect
robots meta inherited from layout
child robots object replacing parent object
CDN stale robots file
Remember metadata nested objects merge shallowly.
JSON-LD debuggingβ
Validate:
HTML-safe serialization
valid JSON
correct Schema.org shape
public URL identity
visible-content consistency
publication state
A rich-results validator passing does not prove the data is truthful.
Caching incident exampleβ
Incident:
article title changed
page shows new title
Google/social preview still shows old title/image
Possible causes:
page data refreshed
metadata data cached separately
OG image route cached separately
social platform cache retained old URL
CDN cached old HTML
Trace each cache layer instead of assuming one global cache exists.
Host leakage incidentβ
Incident:
canonical URLs point to internal service hostname
Trace:
metadataBase source
public origin environment variable
reverse proxy Host/X-Forwarded-* configuration
tenant domain validation
preview fallback behavior
Fix the ownership model, not just one page string.
Publication leak incidentβ
Incident:
unpublished article appears in OG image and sitemap
Root cause often looks like:
page uses public query
but OG/sitemap use generic DB query by slug
Move publication filtering into the shared data boundary.
SEO observabilityβ
Useful logs/metrics:
metadata generation failures
metadata dependency latency
OG generation failures/latency
sitemap generation duration/count
robots response changes
404/410 rate for indexed routes
redirect-chain anomalies
canonical-host mismatch detection
Do not log full private metadata inputs if they may contain sensitive content.
Phase 14 owns full observability implementation.
Automated assertionsβ
Later testing phases can encode invariants such as:
public product page has canonical production host
private dashboard has noindex
published article appears in sitemap
unpublished article does not
OG image route returns image/png
robots.txt returns text/plain
all locale alternates resolve successfully
SEO is testable system behavior.
Build-time validationβ
Production build can catch:
invalid relative metadata URLs without metadataBase
oversized static social-image files
invalid route metadata conventions
TypeScript metadata shape errors
broken handbook/page imports
But build success does not prove crawler correctness.
Production smoke testβ
After deployment, verify a representative matrix:
homepage
static marketing page
dynamic article/product
localized page
private route
redirect source
404/deleted route
robots.txt
sitemap.xml
OG image
manifest/icon
Test the public deployed host.
Senior design review questionsβ
For a proposed SEO architecture, ask:
- What defines the canonical public origin?
- How is canonical path generated?
- What is the publication/publication-filter boundary?
- Which route layers own metadata defaults?
- Which nested metadata fields are intentionally replaced vs extended?
- Which metadata is static, cached, or request-time?
- How do content updates invalidate page/metadata/OG/sitemap output?
- How do previews/staging avoid accidental indexing?
- How are locale alternates derived from real translations?
- How do private routes avoid metadata leaks?
- Does Proxy bypass public metadata resources correctly?
- What is tested automatically?
Architecture example: commerceβ
Product domain
ββ public product query
ββ canonical slug resolver
ββ SEO mapper
ββ publication/availability rules
App Router page
ββ UI
ββ generateMetadata
ββ JSON-LD
ββ notFound/redirect rules
Metadata routes
ββ opengraph-image
ββ sitemap
ββ robots
Shared config
ββ public site origin
ββ supported locales
ββ verification/brand config
This separates domain truth from transport/rendering concerns.
Anti-patternsβ
One global SEO service that knows every routeβ
Creates tight coupling and weak route ownership.
Metadata generated from client stateβ
Search/share identity becomes unstable and unavailable before hydration.
Every query parameter indexedβ
Creates duplicate/thin URL explosion.
Private data in title/social cardsβ
Leaks information through public HTML/image routes.
Fixing crawl problems with robots.txt onlyβ
Ignores status, canonical, noindex, security, and sitemap layers.
Using preview host as canonical automaticallyβ
Pollutes production identity.
Interview questionsβ
How would you debug a page that looks correct in-browser but has the wrong social preview?
Trace the crawler response, canonical/OG tags, image route, file-based precedence, redirects/Proxy, and platform cache separately from browser rendering.
How should page, sitemap, OG image, and JSON-LD agree on publication state?
They should consume a shared public-domain data boundary that enforces publication and tenant visibility rules.
Why is SEO architecture tied to URL architecture?
Canonical, alternates, redirects, sitemaps, and structured data all describe URL identity; metadata cannot repair an incoherent routing model.
What should happen when an article slug changes?
Redirect the old URL to the new canonical URL, emit the new canonical everywhere, update sitemap/internal links, and ensure social/structured data uses the new identity.
Capstone exerciseβ
Design the SEO system for a global marketplace with:
10 million products
12 locales
custom seller storefront domains
preview deployments
scheduled publishing
product slug changes
private seller dashboards
price/availability updates
Produce:
- canonical host/path rules
- locale alternate rules
- metadata ownership tree
- OG generation/cache strategy
- JSON-LD architecture
- sitemap partition strategy
- robots/noindex policy
- publish/unpublish workflow
- Proxy exclusions
- preview/staging policy
- cache invalidation model
- production smoke-test matrix
- incident runbook for wrong canonical/social preview