SvelteKit SSG
Copy it into a new project:
pnpm dlx degit antstanley/blogwright/examples/sveltekit-ssg my-siteSvelteKit with adapter-static, every page prerendered to HTML at build time and served from S3.
| Framework | Mode | Blogwright config | Source |
|---|---|---|---|
SvelteKit + adapter-static |
Static site, prerendered | paths.dist |
examples/sveltekit-ssg |
Deploy it
Section titled “Deploy it”-
Copy the example and start a repository:
Terminal window pnpm dlx degit antstanley/blogwright/examples/sveltekit-ssg my-sitecd my-site && git init -
Set
siteNameandregioninconfig/production.jsonc. -
Add Blogwright, then commit everything, including
pnpm-lock.yaml- the builder installs with--frozen-lockfile:Terminal window pnpm add -D blogwrightgit add -A && git commit -m "Start from the blogwright example" -
Create the infrastructure:
pnpm exec blogwright bootstrap -
Build and publish:
pnpm exec blogwright deploy
What matters
Section titled “What matters”src/routes/+layout.js-prerender = truefor every page, andtrailingSlash = 'always'so/aboutis written asbuild/about/index.html. Without it SvelteKit writesbuild/about.html, and Blogwright’s router - which resolves/aboutto/about/index.html- answers404.vite.config.js- SvelteKit 3 configuration lives in thesveltekit()Vite plugin.adapter-staticwithfallback: '404.html'writes the page the distribution answers misses with.config/production.jsonc-paths.distisbuild.
The files
Section titled “The files”// Blogwright config for this example. Paths are relative to the repository// root, so they assume this directory IS the repository - see README.md.{ "region": "us-east-1", "siteName": "sveltekit-ssg", "paths": { "dist": "build" },}import adapter from '@sveltejs/adapter-static';import { sveltekit } from '@sveltejs/kit/vite';import { defineConfig } from 'vite';
export default defineConfig({ plugins: [ sveltekit({ // Every page is prerendered to build/. The 404.html fallback is the page // Blogwright's distribution answers misses with (status 404). adapter: adapter({ fallback: '404.html' }), }), ],});// Prerender every page at build time.export const prerender = true;// Write /about as about/index.html: Blogwright's router resolves /about to// /about/index.html, never to about.html.export const trailingSlash = 'always';{ "name": "blogwright-example-sveltekit-ssg", "private": true, "type": "module", "packageManager": "pnpm@11.25.0", "scripts": { "dev": "vite dev", "build": "vite build", "preview": "vite preview" }, "devDependencies": { "@sveltejs/adapter-static": "^4.0.0", "@sveltejs/kit": "^3.0.1", "svelte": "^5.57.2", "vite": "^8.3.4" }}Related pages
Section titled “Related pages”- How URLs map to files - why prerendered pages need
trailingSlash - Examples overview - every example, and the conventions they share