SEO Components
1 min read
SEO Components
10 components for search engine optimization and analytics.
PageMeta
Complete SEO meta tags including Open Graph and Twitter cards.
---
import PageMeta from "@components/seo/PageMeta.astro";
---
<head>
<PageMeta
title="Getting Started"
description="Learn how to set up Astroria Docs"
image="/og-image.png"
type="article"
publishedTime="2024-01-15"
modifiedTime="2024-06-01"
/>
</head>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | required | Page title |
| description | string | required | Meta description |
| image | string | - | OG image URL |
| type | 'website' | 'article' | 'website' | Page type |
| publishedTime | string | - | Article publish date |
| modifiedTime | string | - | Article modified date |
SchemaOrg
JSON-LD structured data for rich search results.
---
import SchemaOrg from "@components/seo/SchemaOrg.astro";
---
<head>
<SchemaOrg
type="TechArticle"
title="API Reference"
description="Complete API documentation"
datePublished="2024-01-15"
dateModified="2024-06-01"
/>
</head>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'TechArticle' | 'WebPage' | 'FAQPage' | required | Schema type |
| title | string | required | Page title |
| description | string | required | Page description |
| datePublished | string | - | Publish date |
| dateModified | string | - | Modified date |
CanonicalURL
Auto-generated canonical link tag.
---
import CanonicalURL from "@components/seo/CanonicalURL.astro";
---
<head>
<CanonicalURL />
<!-- Or with custom URL -->
<CanonicalURL url="/docs/guide/" />
</head>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| url | string | current URL | Custom canonical URL |
HreflangTags
Multi-language SEO tags for internationalization.
---
import HreflangTags from "@components/seo/HreflangTags.astro";
---
<head>
<HreflangTags
currentLang="en"
translations={[
{ lang: "en", url: "/docs/guide/" },
{ lang: "es", url: "/es/docs/guide/" },
{ lang: "ja", url: "/ja/docs/guide/" }
]}
/>
</head>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| currentLang | string | required | Current page language |
| translations | { lang: string; url: string }[] | required | Available translations |
StructuredData
Generic JSON-LD schema markup for any schema type.
---
import StructuredData from "@components/seo/StructuredData.astro";
---
<head>
<StructuredData
type="BreadcrumbList"
data={{
itemListElement: [
{ "@type": "ListItem", position: 1, name: "Home", item: "/" },
{ "@type": "ListItem", position: 2, name: "Docs", item: "/docs/" }
]
}}
/>
</head>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'Article' | 'BreadcrumbList' | 'WebPage' | 'FAQPage' | 'HowTo' | required | Schema type |
| data | Record<string, unknown> | required | Schema data |
OpenGraph
Standalone Open Graph and Twitter card tags.
---
import OpenGraph from "@components/seo/OpenGraph.astro";
---
<head>
<OpenGraph
title="Astroria Docs"
description="Premium documentation theme"
image="/og-image.png"
type="website"
siteName="Astroria"
locale="en_US"
twitterCard="summary_large_image"
twitterSite="@astroria"
/>
</head>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | required | Page title |
| description | string | required | Page description |
| image | string | - | OG image URL |
| type | 'website' | 'article' | 'website' | Page type |
| url | string | current URL | Page URL |
| siteName | string | 'Astroria Docs' | Site name |
| locale | string | 'en_US' | Locale code |
| twitterCard | 'summary' | 'summary_large_image' | 'summary_large_image' | Twitter card type |
| twitterSite | string | - | Twitter handle |
AnalyticsTracking
Google Analytics 4 integration.
---
import AnalyticsTracking from "@components/seo/AnalyticsTracking.astro";
---
<head>
<AnalyticsTracking measurementId="G-XXXXXXXXXX" />
</head>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| measurementId | string | required | GA4 measurement ID |
SearchAnalytics
Track search queries and provide analytics.
---
import SearchAnalytics from "@components/seo/SearchAnalytics.astro";
---
<SearchAnalytics enabled={true} />
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enable tracking |
Usage in JS:
// Get popular searches
window.getSearchAnalytics(); // Returns top 10 queries
ArticleAnalytics
Track article views, scroll depth, and time on page.
---
import ArticleAnalytics from "@components/seo/ArticleAnalytics.astro";
---
<ArticleAnalytics
articleId="getting-started"
title="Getting Started Guide"
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| articleId | string | required | Unique article ID |
| title | string | required | Article title |
Tracked Events:
page_view- Initial viewtime_on_page- Seconds spentscroll_depth- 25%, 50%, 75%, 100%
MaintenanceBanner
Site-wide maintenance or incident notice.
---
import MaintenanceBanner from "@components/seo/MaintenanceBanner.astro";
---
<MaintenanceBanner
message="Scheduled maintenance in progress"
estimatedEnd={new Date('2024-06-15T18:00:00')}
type="maintenance"
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| message | string | 'We are currently performing scheduled maintenance.' | Banner message |
| estimatedEnd | Date | - | Estimated completion time |
| type | 'maintenance' | 'incident' | 'planned' | 'maintenance' | Banner type (affects color) |
Types:
maintenance- Yellow backgroundincident- Red backgroundplanned- Blue background