← All framework guides

SvelteKit SEO: 6 checks and how to fix them

These are the SvelteKit-specific checks RankCLI runs, and the fix for each one in SvelteKit's own idiom. SvelteKit renders on the server by default, which removes a whole class of SEO problems before you start.

6 checks
meta-framework
SSR by default

Run all of these against your own site, free and without an account:

npx @rankcli/cli audit -u https://your-site.dev

What SvelteKit gives you for free

  • •SSR by default
  • •Excellent performance (small runtime)
  • •Built-in prerendering
  • •File-based routing
  • •Form actions for progressive enhancement

The checks

warning
SVELTEKIT_NO_LOAD_FUNCTION

Page without load function

Data fetching in +page.svelte bypasses SSR. Use +page.server.ts or +page.ts.

Move data fetching to a load function:

// src/routes/products/+page.server.ts
export async function load({ fetch }) {
  const products = await fetch('/api/products').then(r => r.json());
  return { products };
}
<!-- src/routes/products/+page.svelte -->
<script>
  export let data;
</script>

{#each data.products as product}
  <div>{product.name}</div>
{/each}
warning
SVELTEKIT_NO_LAYOUT_HEAD

Missing svelte:head in layout

Common meta tags should be in a layout for consistency.

Add svelte:head to your layout:

<!-- src/routes/+layout.svelte -->
<script>
  import { page } from '$app/stores';
</script>

<svelte:head>
  <title>{$page.data.title ?? 'Your Site'}</title>
  <meta name="description" content={$page.data.description ?? 'Default description'} />
  <link rel="canonical" href={$page.url.href} />
</svelte:head>

<slot />
notice
SVELTEKIT_NO_PRERENDER

Static pages not prerendered

Static pages should be prerendered for best performance.

Add prerender to static pages:

// src/routes/about/+page.ts
export const prerender = true;

Or set default in svelte.config.js:

kit: {
  prerender: {
    default: true
  }
}
notice
SVELTEKIT_NO_TRAILING_SLASH

Inconsistent trailing slash handling

Configure trailing slash to avoid duplicate content.

Set in svelte.config.js:

kit: {
  trailingSlash: 'never' // or 'always'
}
notice
SVELTEKIT_ENHANCED_IMAGE

Not using enhanced images

SvelteKit supports enhanced images with @sveltejs/enhanced-img.

Install enhanced images:

npm install @sveltejs/enhanced-img
<script>
  import { Image } from '@sveltejs/enhanced-img';
  import heroImage from '$lib/images/hero.jpg';
</script>

<Image src={heroImage} alt="Hero" />
warning
SVELTEKIT_NO_SITEMAP

Missing sitemap

Use svelte-sitemap or generate manually.

Option 1: Use svelte-sitemap

npm install svelte-sitemap
npx svelte-sitemap --domain https://yoursite.com

Option 2: Create src/routes/sitemap.xml/+server.ts:

export async function GET() {
  const pages = ['/', '/about', '/products'];
  const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
      ${pages.map(page => `
        <url>
          <loc>https://yoursite.com${page}</loc>
        </url>
      `).join('')}
    </urlset>`;
  return new Response(sitemap, {
    headers: { 'Content-Type': 'application/xml' }
  });
}

Check your own SvelteKit site

280+ checks including every one above. No signup, nothing leaves your machine.

Run a free audit