Overview of Sveltepress
llms.txt), and integrated search options (Pagefind, DocSearch, Meilisearch).website·Indexed 32 days ago
https://sveltepress.site/SveltePress is a SvelteKit docs and blog site builder inspired by VitePress. It features a default theme with built-in local search, PWA support, internationalization (i18n), and the ability to use Svelte components directly within markdown. The toolkit includes a CLI and supports Svelte 5 and SvelteKit 2.
llms.txt), and integrated search options (Pagefind, DocSearch, Meilisearch).The Blog Theme is designed for editorial sites and chronological publications. It uses Markdown files located in src/posts and includes built-in features such as:
Requirements: The Blog Theme generates a static site and requires @sveltejs/adapter-static and a Pagefind post-build step.
SveltePress provides a zero-config Local Search powered by Pagefind. It is enabled by default and runs entirely in the browser via WebAssembly. During the production build (pnpm build), SveltePress automatically indexes static HTML pages and bundles assets into /pagefind/.
Key Features:
<html lang="...">.Cmd+K (macOS) or Ctrl+K (Windows/Linux). Navigate with Arrow keys, select with Enter, and close with Escape.pnpm dev, a notice is displayed explaining that the full index is only created during production builds..md files for pages and layouts. For example, src/routes/+page.md serves as the home page and src/routes/+layout.md can be used for the root custom layout. Because it preserves full SvelteKit functionality, developers can use +page.server.js, +layout.server.js, and hooks.server.js for server-side logic such as authentication or database connections.<script>
const msg = 'world!' // [svp! hl]
const old = 'old' // [svp! df:-]
const new = 'new' // [svp! df:+]
const focus = 'me' // [svp! !!]
</script>Sveltepress supports standard Markdown and extended syntax. Key supported elements include:
# to ###### syntax.**text**), Strikethrough (~one~ or ~~two~~), and Inline code (`code`).- or *) and Task lists (- [ ] or - [x]).[^1] and expanded at the bottom of the page. The auto-generated footnotes title can be customized via theme.footnoteLabel in the Vite plugin configuration.:heart:, :pizza:).@sveltepress/theme-default package and add it to the sveltepress plugin configuration in your Vite config.pm install @sveltepress/theme-defaultimport { defaultTheme } from '@sveltepress/theme-default'
import { sveltepress } from '@sveltepress/vite'
import { defineConfig } from 'vite'
const config = defineConfig({
plugins: [
sveltepress({
theme: defaultTheme({ /* theme options */ })
})
],
})
export default config@vite-pwa/sveltekit. To enable PWA, pass the pwa option to the default theme. You must also configure files.serviceWorker in svelte.config.js using the SERVICE_WORKER_PATH exported from @sveltepress/theme-default. Additionally, workbox-window must be added as a dev dependency to the project.// svelte.config.js
import adapter from '@sveltejs/adapter-static'
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
import { SERVICE_WORKER_PATH } from '@sveltepress/theme-default'
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.md'],
preprocess: [vitePreprocess()],
kit: {
adapter: adapter(),
files: {
serviceWorker: SERVICE_WORKER_PATH,
},
},
}
export default config# Install the default theme package
npm install @sveltepress/theme-default// vite.config.ts
import { defaultTheme } from '@sveltepress/theme-default'
import { sveltepress } from '@sveltepress/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
sveltepress({
theme: defaultTheme({ /* theme options */ })
})
],
})
versions build to ensure the current state is captured, then run versions create to freeze the outgoing version and set the new version ID as current. Only after this step should you add :::since markers or edits for the new version.# 1. Build current state
pnpm exec sveltepress versions build
# 2. Freeze current and set 8.2 as the new current version
pnpm exec sveltepress versions create 8.2 --label "8.2"
# 3. (Now edit docs and add version="8.2" markers)
# 4. Build and validate
pnpm exec sveltepress versions build
pnpm exec sveltepress versions validate.sveltepress/version-artifacts. This acts as a build cache to speed up production builds. Use the migrate command to convert existing snapshot directories or initialize new sites.pnpm exec sveltepress versions migrate --site-id docs-example