Free Astro tutorials for complete beginners.

Beginner's Guide to Astro

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

Cover image for Astro SEO: A Beginner's Guide to Getting Found on Google
In this guide
  1. 1. Give every page a title and description
  2. 2. Add a canonical link
  3. 3. Add a sitemap and robots.txt
  4. 4. Make links look good when shared
  5. 5. Add structured data
  6. 6. Write good headings and alt text
  7. 7. Link your pages together
  8. 8. Keep it fast
  9. 9. Tell Google your site exists
  10. A checklist
  11. Frequently asked questions

SEO means helping search engines find and rank your site. Astro gives you a head start. Your pages are plain HTML. HTML is the words and layout of a page. And they load fast. But a few things only you can do. This guide covers all of them, most important first.

1. Give every page a title and description

The title shows in search results and browser tabs. The description is the grey text under it. Put both in your layout. The layout is the shared frame around every page. Then 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. Keep descriptions under about 155. Longer ones get cut off. Our meta tag generator shows you a preview as you type.

A canonical link tells search engines the one true address for a page. Without it, they may treat example.com/about and example.com/about/ as two rival 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. It helps search engines find them all. Astro’s integration builds one for you. An integration is an add-on for Astro. Follow how to add a sitemap. Then point to it from public/robots.txt:

User-agent: *
Allow: /

Sitemap: https://example.com/sitemap-index.xml

Someone shares your page on social media or in a chat app. The preview they see 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. JSON is a plain-text format for data. It describes your page to search engines. It can earn richer results, like FAQ dropdowns. In Astro, build the object in the frontmatter. The frontmatter is the code between the dashes at the top. Then 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 Astro Nursery 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. Use <h2> headings for each section, in a sensible order.

Every image needs alt text that describes it. Astro’s Image component requires it. That is a helpful nudge.

Each page should link to related pages on your site. Use words that say where the link goes. “Read our hosting comparison” is better than “click here”. Links inside your site help search engines find pages. They also show how pages relate.

8. Keep it fast

Speed is part of ranking. Astro handles most of this for you. It sends very little JavaScript. JavaScript is the code that makes a page move. Your part is images. Let Astro shrink them. And don’t upload giant files.

9. Tell Google your site exists

Once your site is live, add it to Google Search Console. Then submit your sitemap. Search Console also tells you which pages are indexed. Indexed means Google has them on file. And it shows 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. Every page you add from then on gets them for free.

Frequently asked questions

Is Astro good for SEO?

Yes. Astro makes 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 the friendly people in the official Astro and EmDash Discords. How to ask so people can help.

Keep reading

  1. How Much Does an Astro Website Cost? (Real Numbers)

    An Astro site can cost $0 a year. Here's what's free, what costs money, and what we actually pay for this site, so you can plan before you start.

    Beginner's guides, 6 minute read, November 8, 2026

  2. Domain Name vs Web Hosting: What's the Difference?

    A domain name is your site's address. Hosting is the computer your site lives on. Here's how the two connect, in plain words, and what each one costs.

    Beginner's guides, 4 minute read, November 8, 2026

  3. How to Back Up an Astro Site (It's Easier Than You Think)

    An Astro site is a folder of files, so the backup is GitHub. Here's why that's complete, how to do it in two clicks, and the one thing it doesn't cover.

    Beginner's guides, 5 minute read, November 8, 2026

Try "blog", "deploy" or "EmDash".