Blog
Add a blog next to your docs, with a page that lists the posts.
A blog is a second collection of pages, a layout of your theme that renders the posts, and a custom page that lists them at /blog.
Adding a Blog
Add a Collection of Posts
Keep the pages of the docs and the posts in two folders, like content/docs and content/blog, since a collection of content would include the posts too. defineCollections() defines the posts, with a schema for the fields of their frontmatter:
import { createSite } from "vuesho/config";
import { defineCollections, defineDocs } from "vuesho/content";
import { pageSchema } from "vuesho/schema";
import { z } from "zod";
const docs = defineDocs({ dir: "content/docs" });
const blog = defineCollections({
type: "doc",
dir: "content/blog",
schema: pageSchema.extend({ date: z.string(), author: z.string() }),
});
export default createSite({
docs: docs.toFumadocsSource(),
blog: blog.toFumadocsSource({ baseDir: "blog" }),
});The schema needs zod installed. baseDir puts the posts under /blog, so content/blog/hello.md is at /blog/hello:
---
title: Hello World
description: The first post.
date: 2026-11-01
author: Fuma
---
Our blog is open.Leave the Posts Out of the Sidebar
The sources share one page tree, so the sidebar of the docs lists the posts as a blog folder. "!blog" in the meta.json at the root of the docs leaves the folder out:
{
"pages": ["...", "!blog"]
}With the docs in their own folder, make that folder a root folder instead, as Sidebar of Multiple Sources shows.
Render the Posts
The theme gives the posts their layout, under the key of their source, blog. Without it, the posts render with layouts.default, the docs layout.
import { defineTheme } from "vuesho/theme";
import defaultTheme from "vuesho/theme/default";
import type app from "../vuesho.config";
export default defineTheme<typeof app>({
extends: defaultTheme,
layouts: { blog: () => import("./layouts/BlogPost.vue") },
});The layout receives the post as its page prop, typed with PageOf. A post has its frontmatter in page.data and its content in page.Content, and the home layout gives the page the navbar of your site:
<script setup lang="ts">
import type { PageOf } from "vuesho/client";
import HomeLayout from "vuesho/layouts/home";
import type app from "../../vuesho.config";
defineProps<{ page: PageOf<typeof app, "blog"> }>();
</script>
<template>
<HomeLayout>
<article class="mx-auto w-full max-w-(--fd-layout-width) px-4 py-12">
<h1 class="text-2xl font-semibold">{{ page.pageData.title }}</h1>
<p class="text-fd-muted-foreground">{{ page.data.date }} by {{ page.data.author }}</p>
<div class="prose">
<component :is="page.Content" />
</div>
</article>
</HomeLayout>
</template>List the Posts
The list of posts is a custom page at /blog. Its props run on the server, and return the posts of the language of the page, newest first. getSiteContext() reads the pages of the site:
import { getSiteContext, type SiteLang } from "vuesho/config";
import type app from "../../vuesho.config";
export interface Post {
title: string;
url: string;
date: string;
}
export function listPosts(lang: SiteLang<typeof app>): Post[] {
const posts = getSiteContext<typeof app>()
.getPages(lang)
.flatMap((page) =>
page.type === "blog" ? [{ title: page.data.title, url: page.url, date: page.data.date }] : [],
);
return posts.sort((a, b) => b.date.localeCompare(a.date));
}page.data.date is a string, from the schema of the collection. The page receives the posts as its props, and Link navigates to a post without loading a new document:
<script setup lang="ts">
import { definePage, Link } from "vuesho/client";
import HomeLayout from "vuesho/layouts/home";
import { listPosts, type Post } from "../../server/posts";
import type app from "../../../vuesho.config";
definePage<typeof app>({
data: { title: "Blog" },
props: ({ lang }) => ({ posts: listPosts(lang) }),
});
defineProps<{ posts: Post[] }>();
</script>
<template>
<HomeLayout>
<main class="mx-auto w-full max-w-(--fd-layout-width) px-4 py-12">
<h1 class="mb-6 text-2xl font-semibold">Blog</h1>
<Link
v-for="post in posts"
:key="post.url"
:href="post.url"
class="mb-2 block rounded-lg border p-4 hover:bg-fd-accent"
>
<p class="font-medium">{{ post.title }}</p>
<p class="text-sm text-fd-muted-foreground">{{ post.date }}</p>
</Link>
</main>
</HomeLayout>
</template>listPosts and its module stay on the server, and the browser receives the posts as JSON. ui.layoutProps adds a link to the page in the navbar:
export default createSite({
docs: docs.toFumadocsSource(),
blog: blog.toFumadocsSource({ baseDir: "blog" }),
}).config({
ui: { layoutProps: { links: [{ text: "Blog", url: "/blog" }] } },
});The compiled stylesheet has the Tailwind CSS classes that the UI uses, like the ones above. For other classes, add Tailwind CSS to your site, or write a <style> block.
The posts and the list are generated at build time and listed in the sitemap, and search finds the posts like the pages of the docs.