Astro layouts that keep SEO from drifting
Centralize your head tags and JSON-LD once—then feed it typed inputs everywhere.
The one-place rule
If canonical URLs and Open Graph tags are implemented in multiple files, they will diverge.
Astro makes this easy to avoid:
- put
<head>concerns in aBaseLayout - pass typed inputs: title, description, canonicalPath, imagePath
- generate the final meta from a shared helper
JSON-LD: keep it deterministic
For articles, the rule is simple:
- if required metadata exists, emit Article JSON-LD
- use deterministic fallbacks for optional fields like images
The payoff
When you later add:
- tag pages
- category pages
- RSS
- sitemaps
…you’re reusing the same “truth”, not rewriting it.