Free auditStart free
GuideAstro · Framework guide

Astro SEO

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 withChatGPTClaudePerplexityGoogleAI Mode
01Checklist

Set the deployed URL and route shape first

Astro uses ordinary HTML for page metadata; its config is for build and 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).
First2
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.
Next1
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.
Then1
Make every public route reachable through ordinary links and give duplicate route variants a clear 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 for generated route coverage and the SSR limitation.

02Checklist

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. 01Make the <title>, visible heading, and main copy describe the same page and visitor task.
  2. 02Use a canonical derived from the public route, not an editor preview, query string, or staging domain.
  3. 03Set 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. 04Include Open Graph and social image metadata for sharing where relevant; these tags are not a substitute for useful visible content.
  5. 05Keep robots directives and structured data accurate for the published route. Use noindex for genuine internal or duplicate pages, 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>
03Match 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 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.

Questions

Asked a lot.

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

01Does 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.

02Why 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.

03Does 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.

04Is 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. 01Configuration overview | Astro Docsdocs.astro.build · checked 2026-10-24
  2. 02@astrojs/sitemap | Astro Docsdocs.astro.build · checked 2026-10-24
  3. 03On-demand rendering | Astro Docsdocs.astro.build · checked 2026-10-24
  4. 04SEO Starter Guide | Google Search Centraldevelopers.google.com · checked 2026-10-24
  5. 05JavaScript SEO basics | Google Search Centraldevelopers.google.com · checked 2026-10-24
Free · 2 minutes

Tools point. Agencies advise. This one ships.

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

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane