How to set up SEO tags & Open Graph metadata on a SvelteKit site.
-
Define
PUBLIC_SITE_NAME,PUBLIC_DEFAULT_TITLE, &PUBLIC_DEFAULT_DESCRIPTIONin.env. -
Add
$lib/assets/images/branding/og-default.png. Create a 1200x630 PNG or JPEG. -
Add +layout.svelte within
src/routes/(public)/orsrc/routes/, however you prefer to organize it. -
Add meta.ts within
src/lib/. (Optionally, updateformatTitle()to your preferred title format; the default is<title> · <siteName>.) -
Add app.html within
src/. (This version simplifies the default and moves items into+layout.sveltefor better organization and becauseapp.htmlis never minified by SvelteKit and will ship any comments you make in it.) -
Within each route's load function, include a
metaproperty containing at leasttitleanddescription(usually just those two) and any other properties you want to override the defaults for:import type { Meta } from "$lib/common/meta"; export async function load() { try { const meta: Meta = { title: "Privacy Policy", description: `View our privacy policy`, }; return { meta }; } catch (err) { error(500, "Internal Server Error"); } }
-
Install Super Sitemap, including set up of
robots.txtas detailed in its instructions.
- Claim ownership on Google Search Console
- Claim ownership on Bing Webmaster Tools.