Skip to content
PageAudit

Audit a SvelteKit site's SEO with PageAudit

Write the title and description in svelte:head, serve the sitemap from a route and audit the published page.

Updated

1Write svelte:head

In each +page.svelte, svelte:head carries the page title, description and canonical link.

<svelte:head>
  <title>Example home</title>
  <meta name="description" content="What this page offers, in one sentence." />
  <link rel="canonical" href="https://example.com/" />
</svelte:head>

2Serve the sitemap

Create src/routes/sitemap.xml/+server.js with the site pages. robots.txt goes in the static folder, with a Sitemap line that points to it.

export const prerender = true;
const PAGES = ["/", "/about"];

export function GET() {
  const urls = PAGES.map((p) => `<url><loc>https://example.com${p}</loc></url>`).join("");
  const xml = `<?xml version="1.0" encoding="UTF-8"?>` +
    `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${urls}</urlset>`;
  return new Response(xml, { headers: { "content-type": "application/xml" } });
}

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/"}'