Layout Component
TheLayout is the root layout component for all pages in the Version Counter application. It provides a complete HTML document structure with comprehensive SEO meta tags, Open Graph data, structured data, and consistent page structure with header and footer.
Props Interface
The component exports a TypeScript interface for type-safe props:Page title shown in browser tab and search results
Meta description for SEO and social media previews
Open Graph image for social media sharing
Canonical URL for the page. Auto-generated from current pathname if not provided
Open Graph type (e.g., “website”, “article”)
SEO keywords for search engines. Default includes comprehensive game-related terms
Content author for meta tags
Custom canonical URL. Falls back to
url if not providedHTML language attribute (e.g., “en”, “es”)
Usage Examples
Basic Usage (Home Page)
With Custom Canonical URL
HTML Structure
The Layout component generates a complete HTML document:Head Section
- Basic Meta
- Open Graph
- Twitter Card
- Structured Data
External Resources
Body Structure
SEO Features
Default Keywords
The layout includes comprehensive multilingual keywords:Keywords are normalized with
keywords.replace(/\s+/g, " ").trim() to remove extra whitespace.Canonical URLs
Canonical URLs are automatically generated:Structured Data
The component includes Schema.orgSoftwareApplication structured data for enhanced search results.
Styling
Global Imports
Custom Font
Theme Colors
- Background:
bg-background-dark(custom dark theme) - Text:
text-slate-900 dark:text-slate-100(responsive to dark mode) - Theme color:
#0f172a(slate-900)
Page Structure Components
Header
Imported from../components/Header.astro - provides navigation and branding.
Footer
Imported from../components/Footer.astro - provides footer links and information.
Slot
The<slot /> element is where page-specific content is injected:
Client-Side Routing
The layout includes Astro’s ClientRouter for SPA-like navigation:Responsive Design
- Mobile-first: Uses responsive Tailwind classes
- Dark mode ready: Includes dark mode variants
- Flexible layout:
min-h-screen flex flex-colensures footer stays at bottom
Best Practices
- Always provide a title: Required for SEO and user experience
- Custom descriptions: Override default for each page
- Unique images: Use page-specific OG images for better social sharing
- Canonical URLs: Set explicitly for pages with multiple URLs
- Keywords: Add page-specific keywords to supplement defaults
Source Location
The Layout component is located at:src/layouts/Layout.astro