Stable public page
- Starting point
- Prerender it when its content is known at build time.
- Metadata check
- Built HTML contains the route’s title and description.
Set unique SvelteKit titles and descriptions with load data and svelte:head, then verify server-rendered HTML on dynamic routes.
Return each route’s title and description from its load function, then render them in <svelte:head>. SvelteKit uses SSR by default, so the metadata can be in the initial HTML response. Keep the values unique for each route and inspect the deployed response instead of checking only the browser after JavaScript runs.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
load function, then use it in <svelte:head>. This keeps a dynamic article’s metadata tied to the same record as its visible heading and body. SvelteKit’s SEO docs say every page should have well-written and unique <title> and <meta name="description"> elements inside <svelte:head>, and describe a common pattern: return SEO data from page load functions, then use it as page.data in a <svelte:head> in your root layout. The example below puts the tags in the page instead. Return a real 404 with error(404, ...) when the record does not exist.<script>
let { data } = $props()
</script>
<svelte:head>
<title>{data.title}</title>
<meta name="description" content={data.description} />
</svelte:head>
<h1>{data.article.title}</h1>The example uses a server load function so API credentials and server-only access can stay on the server. For public data, a universal +page.js load can also supply data. The important check is the rendered document: title and description should describe this route, not the entire site or a generic template.
import { error } from '@sveltejs/kit'
export async function load({ params, fetch }) {
const response = await fetch(`/api/articles/${params.slug}`)
if (!response.ok) error(404, 'Article not found')
const article = await response.json()
return {
title: article.seoTitle ?? article.title,
description: article.seoDescription ?? article.summary,
article
}
}head content is exposed separately to the main body content. SvelteKit’s SEO docs say server-rendered content is indexed more frequently and reliably, and that you should leave SSR on unless you have a good reason not to. A client-only metadata update can make the browser tab look correct while the initial response is missing the page’s title and description.Per SvelteKit’s page options, any two users hitting a prerendered page directly must get the same content, and accessing url.searchParams during prerendering is forbidden. Child layouts and pages override values set in parent layouts, so you can enable prerendering for the app and disable it for pages that need dynamic rendering. See SvelteKit page options.
undefined, an empty string, or metadata from another record.By default SvelteKit removes trailing slashes by redirecting: visit /about/ and it responds with a redirect to /about. The trailingSlash page option can be 'never' (the default), 'always', or 'ignore', and the docs advise against 'ignore' because /x and /x/ become separate URLs. Make canonicals and internal links match the form your site uses. See canonical URLs and meta descriptions.
Open a deep URL in a fresh tab or use curl -sL https://example.com/articles/example. A route that works only after navigating from the homepage may have a routing or server-data issue.
Search the response HTML for <title> and name="description". Confirm they describe the requested article before any client-side navigation.
Check two different records, a missing slug, and a record with blank SEO fields. This catches static metadata accidentally reused across a dynamic route family.
Test both trailing-slash forms. Confirm any canonical you render points at the final public URL and the redirect does not loop or add an extra hop.
For Google’s general guidance, see JavaScript SEO basics. A successful HTML check confirms output, not indexing; use URL Inspection and Search Console to investigate indexing separately.
4 questions people ask next, answered from the sources on this page.
Put a <title> inside <svelte:head>. For route-specific pages, return the title from load and render the returned data so each URL gets its own value.
The title may be set only after client-side JavaScript runs, or SSR may be disabled for that route. SvelteKit uses SSR by default, so inspect the direct response and render the title through <svelte:head> with data from load.
Yes. Load the CMS record from the route parameter and render its SEO fields through <svelte:head>. Add a fallback for missing fields, return a 404 for a missing record, and test two different URLs to catch reused metadata.
No. SvelteKit’s docs say a page is prerenderable only if any two users hitting it directly get the same content from the server, and that prerendered content is seen by all users. Pages with actions cannot be prerendered.
Run the free audit, then approve the fixes. Every change can be undone.