← Back to development
dev

Best practice on creating markdown blog in SvelteKit

Why use a markdown blog and what are the best practices when implementing them.

Why use a markdown blog and what are the best practices when implementing them.

A markdown blog is still one of the most practical content setups for a small SvelteKit site.

It works well when you want to keep writing simple, store posts in the repo, and ship a fast static site without adding a database or CMS too early.

Why use markdown at all?

For a personal site or review blog, markdown gives you a few useful properties:

  • posts live beside the codebase
  • content changes can be versioned with Git
  • pages can be prerendered and served statically
  • there is very little maintenance overhead

That tradeoff is usually better than introducing a headless CMS before the site actually needs one.

1. Store posts in a dedicated folder

A clean starting point is a src/posts directory.

Each post should contain frontmatter for the metadata and markdown for the body.

---
title: My Post
description: Short summary shown on listing pages.
date: '2026-03-01'
categories:
  - dev
published: true
imageUrl: /img/example.jpg
---

## Heading

Post content goes here.

The important part is consistency. Once every post follows the same shape, the rest of the site becomes much simpler.

2. Treat frontmatter as page metadata

The frontmatter should not just exist for the sake of the post page.

Use it for:

  • homepage cards
  • category sections
  • SEO title and description
  • Open Graph tags
  • publish filtering

That is what makes the content reusable across the whole site instead of only rendering inside a single article view.

3. Load posts through a dynamic blog route

A typical route looks like this:

// src/routes/blog/[slug]/+page.ts
export async function load({ params }) {
	const post = await import(`../../../posts/${params.slug}.md`);

	return {
		content: post.default,
		meta: post.metadata
	};
}

This keeps the route simple:

  • the slug maps to a markdown file
  • the rendered markdown component becomes the page body
  • the frontmatter becomes metadata for the template

The corresponding Svelte page can then render the image, title, date, description, and markdown content in a normal article layout.

4. Generate post lists from the same source

Once the post files are structured, listing pages become straightforward.

A simple API route or loader can:

  • import all markdown files
  • filter unpublished posts
  • sort by date
  • group by category

That gives you a homepage, review section, development section, and RSS feed without duplicating content in multiple places.

5. Keep the output content-first

One common mistake is building the markdown system correctly but then wrapping it in pages that feel like templates instead of articles.

For a blog, the better approach is:

  • clear summaries on listing cards
  • readable article pages
  • obvious publish dates
  • strong internal navigation
  • minimal filler UI

The content should feel like the center of the site, not something placed inside a generic product shell.

6. Know when markdown stops being enough

Markdown is a good fit when:

  • one person writes the content
  • the publishing flow is Git-based
  • posts do not need complicated editorial workflows

It becomes less ideal when you need:

  • multiple authors editing in a browser
  • scheduled publishing
  • approval workflows
  • rich embedded content managed by non-technical users

At that point, a CMS may make sense. Until then, markdown is usually the simpler and better system.

Final take

If the goal is a fast, maintainable SvelteKit blog, markdown is still a strong default.

It keeps the stack small, makes publishing predictable, and works especially well for review sites, tutorials, and personal development logs.

The important part is not just rendering markdown. The important part is treating each post as structured content with metadata that can power the rest of the site.

Source

https://joyofcode.xyz/sveltekit-markdown-blog