Audit an Astro site's SEO with PageAudit
Put the title, description and canonical link in the layout, generate the sitemap with the official integration and audit the page.
Updated
1Write the layout
In src/layouts/Base.astro, each page passes its title and description. The canonical link uses the site from astro.config.mjs.
---
const { title, description } = Astro.props;
const canonical = new URL(Astro.url.pathname, Astro.site);
---
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{title}</title>
<meta name="description" content={description} />
<link rel="canonical" href={canonical} />
</head>
<body><slot /></body>
</html>2Generate the sitemap
Run npx astro add sitemap and check the site in astro.config.mjs. The integration writes /sitemap-index.xml; point to that address in public/robots.txt.
import { defineConfig } from "astro/config";
import sitemap from "@astrojs/sitemap";
export default defineConfig({ site: "https://example.com", integrations: [sitemap()] });3Audit the published page
Change the address to the published page. The answer brings the score, the counts and each error with its fix. No key: 10 free audits a day.
curl -sS -X POST https://pageaudit.online/api/audit \
-H 'content-type: application/json' \
-d '{"url": "https://example.com/"}'