This repository has been archived on 2025-12-24. You can view files and clone it, but cannot push or open issues or pull requests.
site-template/docs/seo.md
2025-03-07 14:59:06 +01:00

19 lines
607 B
Markdown

# SEO Component for Canonical Tags and Hreflang Attributes in Astro
This document outlines how to implement canonical tags and hreflang attributes in an Astro project to support multilingual SEO.
## 1. SEO Component (`SEO.astro`)
Create a reusable component that accepts a canonical URL and an array of hreflang entries.
```astro
---
// src/components/SEO.astro
const { canonical, hreflangs } = Astro.props;
---
{canonical && <link rel="canonical" href={canonical} />}
{hreflangs &&
hreflangs.map((entry) => (
<link key={entry.lang} rel="alternate" hreflang={entry.lang} href={entry.url} />
))}