# Astro SEO

> Set up Astro SEO around the deployed origin, standard HTML metadata, static versus SSR routes, internal links, and sitemap coverage.

Canonical: https://scaplet.com/seo/astro

Guide Astro Astro · Framework guide

Set up Astro SEO around the deployed origin, standard HTML metadata, static versus SSR routes, internal links, and sitemap coverage.

4 min

read

5

sources

Oct 24, 2026

updated

Scaplet Editorial Team

author

In one line

Astro uses standard HTML tags for SEO metadata; add title, description, canonical, social, and robots tags to each page's head. Set `site` in `astro.config.mjs` to the production origin and `base` only for a subpath deployment. Check generated routes against deployed URLs, choose static or SSR output by page needs, and inspect built HTML before publishing.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%20(%22Astro%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%20(%22Astro%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%20(%22Astro%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fastro%20(%22Astro%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 4 parts, 4 minutes.

1. [Set the deployed URL and route shape first 01](#set-the-deployed-url-and-route-shape-first)
2. [Add page metadata in the shared layout 02](#add-page-metadata-in-the-shared-layout)
3. [Choose static generation or SSR by page behavior 03](#choose-static-generation-or-ssr-by-page-behavior)
4. [Check links, assets, and crawl controls on production 04](#check-links-assets-and-crawl-controls-on-production)

_01_Checklist

## Set the deployed URL and route shape first

Astro uses ordinary HTML for page metadata; its config is for build and [rendering](/glossary/rendering) settings rather than a dedicated metadata model. Set `site` to the canonical production origin. Astro says it uses this URL "to generate your sitemap and canonical URLs in your final build" and strongly recommends setting it. Set `base` if the site is deployed below a path such as `/docs`; Astro then expects asset imports and URLs to carry that prefix (`import.meta.env.BASE_URL`).

First_2_
Use the production protocol and hostname in `site`; preview builds should not publish preview URLs as canonical references.

Set `base` only when the deployment actually serves the project from a path prefix. Ensure links, canonical URLs, and sitemap entries include that base consistently.

Next_1_
`trailingSlash` defaults to `'ignore'` and controls route matching in the dev server and on-demand rendered pages. Astro says trailing slashes on prerendered pages are handled by the hosting platform and may not respect your setting, so inspect deployed routes rather than assuming local behavior is identical.

Then_1_
Make every public route reachable through ordinary links and give duplicate route variants a clear [canonical URL](/glossary/canonical-url).

astro.config.mjs

```
import { defineConfig } from 'astro/config' export default defineConfig({ site: 'https://www.example.com', base: '/docs', trailingSlash: 'always', })
```

Astro's sitemap integration uses the `site` value to write absolute URLs. See [Astro sitemap setup](/seo/astro/xml-sitemap) for generated route coverage and the SSR limitation.

_02_Checklist

## Add page metadata in the shared layout

Put the shared document structure in an Astro layout, then pass page-specific title, description, and canonical data from each route. This keeps common tags consistent while letting articles, products, and landing pages express their own purpose. Avoid placing a single static title and description on every route if those pages serve different needs.

1. 01 Make the `<title>`, visible heading, and main copy describe the same page and visitor task.
2. 02 Use a canonical derived from the public route, not an editor preview, [query string](/glossary/url-parameters), or staging domain.
3. 03 Set `lang` correctly and add alternate-language links only when each translation is a real equivalent page. Astro's sitemap integration adds `hreflang` alternates only if you pass its `i18n` option.
4. 04 Include [Open Graph](/glossary/open-graph) and social image metadata for sharing where relevant; these tags are not a substitute for useful visible content.
5. 05 Keep robots directives and [structured data](/glossary/structured-data) accurate for the published route. Use `noindex` for genuine internal or [duplicate pages](/glossary/duplicate-content), not as a fix for content quality.

A reusable page head

```
--- const { title, description, canonical } = Astro.props --- <html lang="en"> <head> <title>{title}</title> <meta name="description" content={description} /> <link rel="canonical" href={canonical} /> </head> <body><slot /></body> </html>
```

_03_Match rendering mode to the route

## Choose static generation or SSR by page behavior

Astro can prerender pages at build time or render routes on demand when an adapter enables server output. Static output is a strong fit for public content that is known at build time. SSR fits pages needing request-time data, but requires your app to provide the SEO head and route inventory. Astro's sitemap docs say the integration includes statically generated routes, including dynamic routes from `getStaticPaths()`, but "cannot generate sitemap entries for dynamic routes in SSR mode".

Route

### Documentation, articles, or durable service pages

Good starting point

Prerender at build time.

Check

Generated paths and metadata exist in the build output.

Route

### Large CMS route family

Good starting point

Static generation if records are available at build time.

Check

`getStaticPaths()` returns the intended canonical paths and build can handle the volume.

Route

### Fresh or request-specific data

Good starting point

SSR with a compatible adapter.

Check

Server response includes correct metadata and private data is not made public.

Route

### User account or app screen

Good starting point

Client or [server rendering](/glossary/server-side-rendering) behind access controls.

Check

Page should not be exposed in sitemap or search results unless deliberately public.

For a hybrid project, check the rendered route, not just the overall Astro mode. A page that appears after client JavaScript runs may not provide the same first response that a static HTML page provides.

_04_How it works

## Check links, assets, and crawl controls on production

1. 1

### Build and inspect representative pages

Check source HTML for title, description, canonical, language, robots, heading, and primary content across one route per template.
2. 2

### Check canonical links and redirects

Request the slash and non-slash variants, old URLs, and common query variants. Confirm they resolve to one canonical route without a chain.
3. 3

### Publish robots and sitemap discovery

Use the correct production sitemap index in robots.txt and submit it under the matching Search Console property.
4. 4

### Fix mobile and performance problems that affect use

Inspect the final page for oversized scripts, unoptimized images, layout shifts, and inaccessible navigation. Keep client islands only where interaction needs them.
5. 5

### Review Search Console evidence

Compare query and page results, inspect indexing exclusions, and use URL Inspection to diagnose important URLs that are crawled but not indexed.

For Google's principles, see the [SEO Starter Guide](https://developers.google.com/search/docs/fundamentals/seo-starter-guide). Sitemap submission helps discovery but does not guarantee crawling or indexing.

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ Does Astro have built-in SEO meta tags?

Astro's config is for build and rendering settings, not common SEO metadata. Add standard HTML title, meta, and link tags to the page head, usually through a shared layout with route-specific values.

_02_ Why should I set `site` in Astro config?

Astro uses the full URL in `site` to generate your sitemap and canonical URLs in the final build. Set it to the production origin, not a local or preview domain.

_03_ Does Astro's sitemap include SSR routes?

The official integration includes statically generated routes, including `getStaticPaths()` output, but Astro says it cannot generate sitemap entries for dynamic routes in SSR mode.

_04_ Is Astro SEO good for large content sites?

Astro can build large static route sets, but you should test build time, output size, and route completeness. Make sure each indexed page has distinct value and is linked from useful site sections.

Sources · 5

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- astro.build
- google.com

1. 01 [Configuration overview | Astro Docs](https://docs.astro.build/en/guides/configuring-astro/) docs.astro.build · checked 2026-10-24
2. 02 [@astrojs/sitemap | Astro Docs](https://docs.astro.build/en/guides/integrations-guide/sitemap/) docs.astro.build · checked 2026-10-24
3. 03 [On-demand rendering | Astro Docs](https://docs.astro.build/en/guides/on-demand-rendering/) docs.astro.build · checked 2026-10-24
4. 04 [SEO Starter Guide | Google Search Central](https://developers.google.com/search/docs/fundamentals/seo-starter-guide) developers.google.com · checked 2026-10-24
5. 05 [JavaScript SEO basics | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics) developers.google.com · checked 2026-10-24

## Keep learning

[All platform guides](/seo)

[Learn Astro robots.txt Frameworks](/seo/astro/robots-txt) [Related Canonical URL Crawling and indexing](/glossary/canonical-url) [Read next Astro redirects Frameworks](/seo/astro/redirects) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in platform guides
[Yoast SEO plugin setup](/seo/yoast/seo) [Astro 404 page](/seo/astro/404) [Astro Google Analytics](/seo/astro/google-analytics)

More in Frameworks
[Angular SEO](/seo/angular) [Astro SEO](/seo/astro) [Gatsby SEO](/seo/gatsby) [Next.js SEO](/seo/nextjs) [Nuxt SEO](/seo/nuxt)

Terms on this page
[Rendering](/glossary/rendering) [Canonical URL](/glossary/canonical-url) [URL parameters](/glossary/url-parameters) [Open Graph](/glossary/open-graph) [Structured data](/glossary/structured-data) [Duplicate content](/glossary/duplicate-content) [Server-side rendering](/glossary/server-side-rendering)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
