The initial project and adapting to SvelteKit 3
The starting choices for the static blog and how SvelteKit 3 and mdsvex 1.x differ from the documentation you find around the web.

The first goal was simple to state: a blog generated entirely at build time and uploaded via FTP. The list of things I wanted from day one, on the other hand, was long.
What had to be there from the start
- Tailwind with the typography plugin and a flash-free dark theme;
- adapter-static with a custom
404.htmlpage; - authors described in YAML files, with Gravatar or a fallback avatar;
- Markdown articles with frontmatter, compiled by mdsvex;
- hierarchical categories, tags and paginated archives, all static;
- author pages, prerendered JSON APIs, JSON-LD, sitemap and RSS;
- FTP deployment with GitHub Actions.
The key part is in the root layout:
export const prerender = true;
export const trailingSlash = 'always';Every page becomes folder/index.html, and any web server can serve it without rewrite rules.
The surprise: SvelteKit 3
Almost all the documentation and examples you find online are written for SvelteKit 2. Some things changed in version 3, and I discovered them one at a time.
No more svelte.config.js
Kit's configuration (adapter, prerender, paths) is passed directly to the sveltekit() plugin in vite.config.ts. In fact, if svelte.config.js exists, the build breaks.
sveltekit({
extensions: ['.svelte', '.md'],
preprocess: [vitePreprocess()],
adapter: adapter({ fallback: '404.html', strict: true }),
paths: { relative: false },
prerender: { handleHttpError: 'fail' }
})With handleHttpError: 'fail' the build stops on any broken internal link: that's the guarantee I was asking for in the requirements.
#lib instead of $lib
The alias for the src/lib folder is now #lib, defined in the imports field of package.json. For modules that aren't components you also need to include the extension:
import { SITE_URL } from '#lib/config.ts';mdsvex 1.x is a Vite plugin
It's no longer a preprocessor: it has to be registered among the Vite plugins, before sveltekit(). I parse the frontmatter with js-yaml, which in its current version has no default export:
import { JSON_SCHEMA, load } from 'js-yaml';
mdsvex({
extensions: ['.md'],
frontmatter: {
parse: (raw) => load(raw, { schema: JSON_SCHEMA }) as Record<string, unknown>
}
});The JSON_SCHEMA schema keeps dates from turning into Date objects: they stay strings, and that will come in handy later.
Markdown that becomes Svelte
mdsvex compiles every article as a Svelte component, so some rules of "classic" Markdown don't apply:
| Effect | Syntax |
|---|---|
| bold | one asterisk on each side |
| italic | one underscore on each side |
| hard line break | \ at the end of the line |
In regular text, curly braces must be written as HTML entities ({ and }), otherwise Svelte reads them as expressions. In code blocks, mdsvex takes care of it for you.
Tip: when something doesn't add up with SvelteKit 3, check the date of the example you're following first.
With the configuration in place I started the local preview (npm run build and then npm run preview) and the blog came to life. In the next article we'll look at how articles, authors and taxonomies are organized.