Layout Component
TheLayout.astro component is the main layout wrapper used across all pages in Andrew Gao’s personal website. It provides consistent structure, SEO optimization, and navigation.
Location
~/workspace/source/src/layouts/Layout.astro
Props
The Layout component extends theHead.astro props and adds additional layout customization options.
Page title that appears in browser tab and SEO meta tags
Meta description for SEO and social media previews
Current page path used for canonical URL (e.g.,
/blog, /projects)Open Graph image URL for social media sharing. Defaults to
/background.jpgAdditional CSS classes applied to the default slot container
Additional CSS classes applied to the
<body> elementAdditional CSS classes applied to the
<main> elementWhether the navigation should be sticky/fixed at the top of the page
TypeScript Interface
~/workspace/source/src/layouts/Layout.astro:8-26 for the full interface definition.
Slots
The Layout component provides multiple slots for flexible content organization:- Default slot: Main page content with automatic padding and responsive max-width
headslot: Additional elements to inject into<head>(e.g., external stylesheets)main-p-0slot: Content placed in<main>without default padding (useful for full-width components like maps)
Usage Examples
Basic Page Layout
~/workspace/source/src/pages/index.astro:25-29 for a real example.
Layout with Custom Classes
~/workspace/source/src/pages/blog/[slug].astro:30 for this pattern in use.
Layout with Non-Fixed Navigation
~/workspace/source/src/pages/index.astro:25-29 for the home page implementation.
Full-Width Content with Slots
~/workspace/source/src/pages/places.astro:27-43 for the places/map page example.
Features
Automatic SEO
The Layout component automatically includes:- Meta tags via the
Head.astrocomponent - Open Graph tags for social sharing
- Twitter Card metadata
- Canonical URL generation
Responsive Padding
Default content padding adapts based onisNavigationFixed:
- Fixed navigation:
pt-13(top padding) - Non-fixed navigation:
pt-3(top padding) - Horizontal padding:
px-5on mobile,md:px-0on desktop
Navigation Integration
Automatically renders theNavigation.astro component with:
- Gradient overlay when navigation is fixed
- Consistent z-index layering
- Responsive behavior
Related Components
- Head Component - SEO meta tags
- Navigation Component - Header navigation