A SvelteKit blog SEO guide comes down to five checks: full HTML in the first response, per-post head tags built from one front-matter schema, an accurate sitemap, consistent canonical URLs, and JSON-LD that matches the visible page. SvelteKit renders on the server by default, according to the SvelteKit SEO docs. Most of the work is keeping that default and wiring the other four checks to front matter.

This is for developers whose posts are Markdown files in a Git repository. A search engine reads each file as a finished page with its own title, description and URL, so front matter becomes the single source of truth for every SEO field.

Key Takeaways

  • One front-matter schema can feed the head tags, sitemap, RSS feed and JSON-LD, so each field is edited once.
  • One export const ssr = false in a layout strips server-rendered HTML from every post beneath it that doesn’t override it.
  • Fill <lastmod> from the real updated date, and leave <priority> and <changefreq> out of the sitemap.
  • Structured data must describe content readers can see, per Google’s structured data guidelines, so build JSON-LD from the fields that render the page.

SvelteKit blog SEO guide: how should you structure the project?

A SvelteKit blog stays easy to audit when each SEO task lives in one file and every file reads the same front-matter schema.

  1. Scaffold the project. Run npx sv create my-blog, the command the SvelteKit docs give for starting a new app. Then install mdsvex, add it to preprocess in svelte.config.js, and list .md in the extensions array so post files render as pages.

  2. Create the file map. Each path owns one SEO task:

src/lib/posts.ts                        shared loader and schema check
src/posts/*.md                          posts with front matter
src/routes/blog/[slug]/+page.server.ts  loads one post, returns 404 if missing
src/routes/blog/[slug]/+page.svelte     head tags and JSON-LD
src/routes/sitemap.xml/+server.ts       sitemap
src/routes/rss.xml/+server.ts           feed
static/robots.txt                       crawl rules
  1. Define the front-matter schema once. The mdsvex documentation says front matter is exposed as metadata, and layouts receive it. A post with these six keys therefore arrives in your code as properties of metadata:
---
title: SvelteKit blog SEO guide
description: One plain sentence of 120 to 160 characters.
date: 2026-03-02
updated: 2026-03-20
canonical: https://example.com/blog/sveltekit-blog-seo-guide
draft: false
---
  1. Write one loader in src/lib/posts.ts. Use import.meta.glob('/src/posts/*.md', { eager: true }), read each module’s metadata, throw if a required key is missing, and sort by date. Every route in the file map imports this function, so a missing description fails the build instead of shipping an empty tag.

To write posts in this shape, see our shortlist of AI SEO writing tools for developer blogs.

Does SvelteKit serve blog posts as full HTML for Google?

SvelteKit serves blog posts as full HTML in the first response by default, and it can also prerender them at build time. Setting ssr to false, including in a layout that child pages inherit, removes that HTML.

The SvelteKit page options docs describe the default: “Normally, SvelteKit renders your page on the server first and sends that HTML to the client where it’s hydrated.” The SvelteKit SEO docs say SvelteKit “employs SSR by default” and advise leaving it on unless you have a good reason not to.

Four page options shape this behavior: ssr, csr, prerender and trailingSlash. You export them from +page.ts, +page.server.ts, +layout.ts or +layout.server.ts. To prerender every post, set the option once in the blog layout:

// src/routes/blog/+layout.ts
export const prerender = true;

The docs explain why this suits posts: “at least some routes of your app can be represented as a simple HTML file generated at build time.” With adapter-static, the static site generation docs say you can “prerender your site as a collection of static files.” Each post then ships as an HTML file.

Layout inheritance can switch server rendering off for every post at once. The docs state that “Child layouts and pages override values set in parent layouts,” so an export const ssr = false in a layout applies to every post beneath it unless a post overrides it.

With ssr off, the docs say SvelteKit “renders an empty ‘shell’ page instead.” Search your layouts for that line before blaming content.

The belief that bots can’t run JavaScript is out of date. Google’s JavaScript SEO basics say Google “processes JavaScript web apps in three main phases”: crawling, rendering and indexing. Rendering is a separate step, so client-rendered content reaches the index through an extra stage.

Serving HTML in the first response skips that stage. The SvelteKit docs put it this way: “server-side rendered content is indexed more frequently and reliably.”

How do you add SEO meta tags to a SvelteKit blog post?

You add SEO meta tags to a SvelteKit blog post by returning the post’s front-matter fields from +page.server.ts and printing them inside <svelte:head> in +page.svelte. Two files and one layout are enough.

  1. Return the metadata from the server load function. Build the canonical URL here, from one configured site origin plus the slug. A missing post should throw a 404 instead of rendering an empty page.
// src/routes/blog/[slug]/+page.server.ts
import { error } from '@sveltejs/kit';
import { getPost } from '$lib/posts';
import { SITE_URL } from '$lib/config';

export async function load({ params }) {
  const post = await getPost(params.slug);
  if (!post) error(404, 'Post not found');

  return {
    post: {
      title: post.title,
      description: post.description,
      html: post.html,
      canonical: `${SITE_URL}/blog/${post.slug}`
    }
  };
}
  1. Render the tags in <svelte:head>. Every value comes from data.post, so editing front matter changes the head with no template edits.
<!-- src/routes/blog/[slug]/+page.svelte -->
<script lang="ts">
  let { data } = $props();
  const post = $derived(data.post);
</script>

<svelte:head>
  <title>{post.title}</title>
  <meta name="description" content={post.description} />
  <link rel="canonical" href={post.canonical} />
  <meta property="og:title" content={post.title} />
  <meta property="og:description" content={post.description} />
  <meta property="og:url" content={post.canonical} />
  <meta property="og:type" content="article" />
</svelte:head>

<article>
  <h1>{post.title}</h1>
  {@html post.html}
</article>
  1. Render child pages in the blog layout. Svelte 5 layouts take children from $props() and print it with {@render children()}, as the SvelteKit routing docs show.
<!-- src/routes/blog/+layout.svelte -->
<script lang="ts">
  let { children } = $props();
</script>

<main>{@render children()}</main>

Use an absolute canonical URL. Google’s canonical documentation says to “use absolute paths rather than relative paths with the rel=“canonical” link element.”

These tags state your preference, and Google makes the final call. Its snippet documentation says Google “uses the meta description tag if it might give users a more accurate description than would be possible purely from the on-page content.”

Its title link documentation says the goal of a title link is “to best represent and describe each result,” so the displayed title can differ from your <title>.

How do you add BlogPosting JSON-LD to a SvelteKit post?

You add BlogPosting JSON-LD to a SvelteKit post by building the object from the same front-matter fields the page displays, serializing it in +page.server.ts, and printing it in a script tag inside <svelte:head>.

Google’s Article structured data documentation lists headline, image, datePublished, dateModified and author among its recommended properties. None of them blocks valid markup when absent.

  1. Build the object in src/routes/blog/[slug]/+page.server.ts. Read every value from the post you already load for the head tags. Map date to datePublished and updated to dateModified. Leave dateModified out when updated is empty, because an invented date would not match the page.
  2. Serialize and escape. Call JSON.stringify, then replace each < with \u003c. Without this, a title containing </script> would close the tag early.
const jsonLd = {
  '@context': 'https://schema.org',
  '@type': 'BlogPosting',
  headline: post.title,
  description: post.description,
  image: post.image,
  datePublished: post.date,
  ...(post.updated && { dateModified: post.updated }),
  author: { '@type': 'Person', name: post.author }
};

return {
  post,
  jsonLd: JSON.stringify(jsonLd).replace(/</g, '\\u003c')
};
  1. Print it in +page.svelte. Use {@html} inside <svelte:head>, since Svelte would otherwise treat the script contents as markup:
<svelte:head>
  {@html `<script type="application/ld+json">${data.jsonLd}</script>`}
</svelte:head>
  1. Compare it with the visible page. The headline, author name and dates in the JSON must equal what readers see on screen. Google’s structured data policies say: “Don’t mark up content that is not visible to readers of the page.”

Valid markup has no guaranteed payoff. Google’s policies state: “Google does not guarantee that features that consume structured data will show up in search results.”

How do you build a sitemap and RSS feed for a SvelteKit blog?

A SvelteKit sitemap is an endpoint that maps your real post list to <url> entries, and an RSS feed is a second endpoint that reads the same list. The SvelteKit SEO docs say you can create a sitemap dynamically using an endpoint but leave the entries for you to fill in.

Both files call one loader, getPublishedPosts(), so URLs and dates can’t drift apart.

  1. Create src/routes/sitemap.xml/+server.ts. Map each post to a <loc> with an absolute canonical URL and a <lastmod> from the updated key, falling back to date. Use ISO 8601 dates. export const prerender = true writes the file at build time.
import { getPublishedPosts } from '$lib/posts';
import { SITE_URL } from '$lib/site';

export const prerender = true;

export async function GET() {
  const posts = await getPublishedPosts();
  const urls = posts
    .map((p) => `<url><loc>${SITE_URL}/blog/${p.slug}</loc><lastmod>${p.updated ?? p.date}</lastmod></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' } });
}
  1. Keep the list to indexable pages, so tag and pagination pages stay out unless you want them in search results. Set updated only when the content changes. Google’s sitemap guide says it ignores <priority> and <changefreq> values, so leave both out. It uses <lastmod> only when it’s consistently accurate.

  2. Point crawlers at the file. Add static/robots.txt with an absolute URL, or submit the sitemap in Search Console.

User-agent: *
Allow: /

Sitemap: https://example.com/sitemap.xml
  1. Create src/routes/rss.xml/+server.ts. Loop over the same getPublishedPosts() result. Each <item> gets the post URL the sitemap uses, a pubDate from new Date(p.date).toUTCString(), and a title and description with &, < and > escaped. Return it with Content-Type: application/rss+xml and the same prerender export.

Google’s guide says all formats limit a single sitemap to 50MB (uncompressed) or 50,000 URLs. A blog with hundreds of posts stays far below that.

How do you avoid duplicate URLs and soft 404s on a SvelteKit blog?

You avoid duplicate URLs and soft 404s on a SvelteKit blog by choosing one URL form per post, deciding which archive pages may be indexed, and returning a real 404 status for slugs that don’t exist.

Pick one form of each URL

SvelteKit’s page options docs list three values for trailingSlash: 'never' (the default), 'always' and 'ignore'. With 'ignore', /blog/my-post and /blog/my-post/ both respond, which gives one post two URLs.

The SvelteKit SEO docs say the framework “redirects pathnames with trailing slashes to ones without (or vice versa depending on your configuration), as duplicate URLs are bad for SEO.” Set the value on purpose in the blog layout:

// src/routes/blog/+layout.ts
export const trailingSlash = 'never';

Use redirects for the slash and host variants, and add rel="canonical" for the rest. Google chooses the canonical itself, so your tag is a signal it can overrule.

Decide what tag and pagination pages do

A tag page that only repeats post titles adds a thin near-copy of pages you already have. Index a tag page only if it has its own useful intro and list. Otherwise add <meta name="robots" content="noindex"> and leave it out of the sitemap.

Google’s robots meta tag documentation says noindex means “Do not show this page, media, or resource in search results.”

Don’t also block those pages in robots.txt. Google’s indexing documentation says that for noindex to work, “the page or resource must not be blocked by a robots.txt file.” A blocked crawler never reads the tag.

Return a real 404 for missing posts

If /blog/typo-slug renders a “not found” message with a 200 status, crawlers receive a valid page with no content. Call error from @sveltejs/kit in the load function instead. The SvelteKit docs describe it as something that “Throws an error with a HTTP status code and an optional message.”

// src/routes/blog/[slug]/+page.server.ts
import { error } from '@sveltejs/kit';

export function load({ params }) {
  const post = getPost(params.slug);
  if (!post) error(404, 'Post not found');
  return { post };
}

Here getPost stands for whatever function looks a slug up in your front-matter list.

What does this SvelteKit blog SEO guide check before a post goes live?

A SvelteKit post is ready to go live when its raw HTML, its JSON-LD and its generated sitemap all match its front matter.

  1. Run curl -s http://localhost:5173/blog/your-slug and look for the <title>, description, canonical and og: tags in the raw HTML.
  2. Find the application/ld+json block in the post’s raw HTML and run it through Google’s Rich Results Test. Expect the test to detect the markup with no errors.
  3. Run npm run build and open the generated sitemap.xml. Every <loc> should be an absolute URL, and every <lastmod> should match a front-matter date.

Okupter’s SvelteKit SEO checklist says SvelteKit’s tools “do not guarantee rankings, traffic or sales.” A post that passes every check can still rank nowhere, and Google may choose not to index it.

The approval pipeline keeps topic, draft and publish waiting for a person, and claims that can’t be matched to their source block the draft gate. You can start setup when you want to connect a repository.

Frequently asked questions

Is SvelteKit good for SEO?

A SvelteKit blog can rank well when each post is served as complete HTML with its own title, meta description and canonical URL, and when the sitemap lists only indexable posts. Nothing guarantees rankings, and Google decides what it indexes.

Do I need prerendering for a blog?

Server rendering already returns full HTML, so prerendering is optional. It suits posts that only change when you deploy, because the SvelteKit docs say such routes can be generated as simple HTML files at build time.

Does Google read priority and changefreq in a sitemap?

Google ignores both tags. Its sitemap documentation says it uses <lastmod> only when the value is consistently and verifiably accurate, so fill it from the post’s real update date.

Should I use trailing slashes on blog URLs?

Pick one form and keep it. SvelteKit removes trailing slashes by default, and the trailingSlash page option changes that. Make your canonical tags and sitemap URLs match whichever form you choose.

Do I need JSON-LD to rank?

JSON-LD isn’t required to rank. Google doesn’t guarantee that correctly marked-up structured data will appear in results, so add BlogPosting markup that matches the visible page and treat it as a description of that page.

Next steps after this SvelteKit blog SEO guide

Apply this SvelteKit blog SEO guide in order, starting with the front-matter schema, because every other file reads it.

Today, define the schema (title, description, date, updated date and canonical) and write the shared loader every route reads.

This week, add the head tags, BlogPosting JSON-LD, sitemap, robots.txt and the feed. Each new post then needs only a Markdown file.

To get cited drafts committed to your repository, see what BirchSeek can do and start setup. Nothing publishes until you approve it.

Sources

SEO • SvelteKit Docs · General structured data guidelines | Google Search Central · Creating a project • SvelteKit Docs · mdsvex documentation · Page options • SvelteKit Docs · Static site generation • SvelteKit Docs · Understand JavaScript SEO Basics | Google Search Central · Build and Submit a Sitemap | Google Search Central. Every other source is linked where the article cites it.