Skip to content

SEO Components

SEO components handle meta tags, structured data, and navigation aids.

Main SEO component for meta tags:

---
import SEO from '@/components/seo/SEO.astro';
---
<head>
<SEO
title="Page Title"
description="Page description for search results"
image="/og-image.png"
imageAlt="Description of the image"
/>
</head>
  • <title> with site name suffix
  • meta description
  • Canonical URL
  • Open Graph tags (og:title, og:description, og:image, etc.)
  • Twitter Card tags
  • robots meta (if noindex/nofollow)
PropTypeDefaultDescription
titlestringPage title
descriptionstringSite descriptionMeta description
imagestringDefault OG imageOG image URL
imageAltstringOG image alt text
noindexbooleanfalsePrevent indexing
nofollowbooleanfalsePrevent following
articleobjectArticle metadata

Structured data component:

---
import JsonLd from '@/components/seo/JsonLd.astro';
import { createBlogPostSchema, createBreadcrumbSchema } from '@/lib/schema';
const blogSchema = createBlogPostSchema({
title: post.data.title,
description: post.data.description,
url: Astro.url.href,
image: ogImageUrl,
datePublished: post.data.publishedAt,
author: { name: post.data.author },
});
const breadcrumbs = createBreadcrumbSchema([
{ name: 'Home', url: '/' },
{ name: 'Blog', url: '/blog' },
{ name: post.data.title, url: Astro.url.href },
]);
---
<JsonLd schema={[blogSchema, breadcrumbs]} />
HelperUse Case
createWebsiteSchema()Homepage
createOrganizationSchema()About page, homepage
createBlogPostSchema(post)Blog posts
createBreadcrumbSchema(items)Any page with breadcrumbs
createFAQSchema(faqs)FAQ pages

Breadcrumb navigation component:

---
import Breadcrumbs from '@/components/seo/Breadcrumbs.astro';
---
<Breadcrumbs
items={[
{ label: 'Home', href: '/' },
{ label: 'Blog', href: '/blog' },
{ label: 'Current Article' },
]}
/>
  • Proper semantic markup (<nav> with aria-label)
  • JSON-LD breadcrumb schema
  • Current page indication
  • Customizable separator
PropTypeDefaultDescription
itemsBreadcrumbItem[]Breadcrumb items
separatorstring'/'Separator character
---
import SEO from '@/components/seo/SEO.astro';
import JsonLd from '@/components/seo/JsonLd.astro';
import { createWebsiteSchema, createOrganizationSchema } from '@/lib/schema';
---
<head>
<SEO
title="Home"
description="Welcome to our website"
/>
<JsonLd schema={[
createWebsiteSchema(),
createOrganizationSchema(),
]} />
</head>
---
import SEO from '@/components/seo/SEO.astro';
import JsonLd from '@/components/seo/JsonLd.astro';
import { createBlogPostSchema } from '@/lib/schema';
---
<head>
<SEO
title={post.title}
description={post.description}
image={`/og/blog/${post.slug}.png`}
article={{
publishedTime: post.publishedAt.toISOString(),
authors: [post.author],
tags: post.tags,
}}
/>
<JsonLd schema={createBlogPostSchema(post)} />
</head>
---
import JsonLd from '@/components/seo/JsonLd.astro';
import { createFAQSchema } from '@/lib/schema';
const faqs = await getCollection('faqs');
---
<JsonLd schema={createFAQSchema(faqs)} />