Astro SEO: A Beginner's Guide to Getting Found on Google
Everything an Astro site needs to rank: titles, descriptions, canonical links, a sitemap, social previews and structured data, with code you can copy.
Tested on Astro 7.4

In this guide
Astro gives you a head start on search engines. Your pages are plain HTML, and they load fast. But a few things only you can do. This guide covers all of them, in order of importance.
1. Give every page a title and description
The title is what shows in search results and browser tabs. The description is the grey text under it. Put both in your layout, and pass them in from each page:
---
const { title, description } = Astro.props;
---
<head>
<title>{title}</title>
<meta name="description" content={description} />
</head>
Keep titles under about 60 characters and descriptions under about 155, or they get cut off. Our meta tag generator shows you a preview as you type.
2. Add a canonical link
A canonical link tells search engines the one true address for a page, which stops them treating example.com/about and example.com/about/ as two competing pages. Set site in astro.config.mjs, then add this to your layout’s <head>:
---
const canonical = new URL(Astro.url.pathname, Astro.site);
---
<link rel="canonical" href={canonical} />
3. Add a sitemap and robots.txt
A sitemap lists every page so search engines can find them all. Astro’s integration builds one for you. Follow how to add a sitemap, then point to it from public/robots.txt:
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap-index.xml
4. Make links look good when shared
When someone shares your page on social media or in a chat app, the preview comes from Open Graph tags. Add them to your layout:
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={canonical} />
<meta property="og:image" content={new URL('/share.png', Astro.site)} />
<meta name="twitter:card" content="summary_large_image" />
The image should be 1200 by 630 pixels. Put it in public.
5. Add structured data
Structured data is a small block of JSON that describes your page to search engines, and it can earn richer results, like FAQ dropdowns. In Astro, build the object in the frontmatter and print it with set:html:
---
const schema = {
'@context': 'https://schema.org',
'@type': 'Article',
headline: title,
description,
datePublished: '2026-11-06',
};
---
<script type="application/ld+json" set:html={JSON.stringify(schema)} />
This is how every guide on AstroBeginner does it.
6. Write good headings and alt text
Search engines read your headings to understand the page. Use one <h1> with the page’s main topic, and <h2> headings for each section, in a sensible order.
Every image needs alt text that describes it. Astro’s Image component requires it, which is a helpful nudge.
7. Link your pages together
Each page should link to related pages on your site, using words that describe where the link goes. “Read our hosting comparison” is better than “click here”. Internal links help search engines find pages and understand how they relate.
8. Keep it fast
Speed is part of ranking. Astro handles most of this for you by sending little JavaScript. Your part is images: let Astro optimize them, and don’t upload giant files.
9. Tell Google your site exists
Once your site is live, add it to Google Search Console and submit your sitemap. Search Console also tells you which pages are indexed and which searches bring people in.
A checklist
- Title and description on every page
- Canonical link
- Sitemap and robots.txt
- Open Graph tags and a share image
- Structured data on articles
- One
<h1>per page, and alt text on images - Internal links between related pages
- Submitted to Google Search Console
Do these once in your layout, and every page you add from then on gets them for free.
Frequently asked questions
Is Astro good for SEO?
Yes. Astro produces plain HTML pages that load fast and are easy for search engines to read. The parts you still have to get right are the ones in this guide.
Do I need an SEO plugin for Astro?
No. Everything in this guide is a few lines in your layout. Some community packages bundle it up, but you don't need one.
How long until Google shows my site?
Usually days to a few weeks after you submit your sitemap in Google Search Console. New sites with little content take longer to rank.
Stuck on a step?
Check the common errors guide, look up a word in the glossary, or ask in the official Astro Discord, where the support channels are friendly to beginners.