Build a blog
Build a blog with Markdown posts, authors, drafts, paging, tags, RSS and a sitemap by following samples/Bevel.SampleBlog.
On this page
dotnet new install Bevel.Templates
dotnet new bevel-blog -n MyBlog
cd MyBlog
dotnet watch
That gives you a blog to start from. This page walks through the bigger samples/Bevel.SampleBlog so you can see every part. Run it with dotnet watch --project samples/Bevel.SampleBlog.
The post record
You describe a post once. Bevel reads each .md file, binds the front matter to this record, and generates data.Posts.
[DataSource("Posts", "./**/*.md", OrderBy = "Date desc, Title")]
[Process<DropDrafts>(Order = -1)]
[Process<PostStats>]
public sealed record BlogPost(
[Unique(IgnoreCase = true)] string Slug,
string Title,
[GroupByDate("Archive", GroupPeriod.Month)]
DateOnly Date,
string Summary,
[GroupBy("Tags")] string[] Tags,
[GroupBy("Categories")] string Category,
bool Featured,
[Reference("Authors")] Author Author,
string RawMarkdown,
[Process<FirstParagraph>(nameof(RawMarkdown))]
string Excerpt = "",
// Optional list reference: front matter `contributors: [ada]`; absent means null (see PostPage).
[Reference("Authors", Required = false)]
IReadOnlyList<Author>? Contributors = null,
int WordCount = 0,
int ReadingMinutes = 0,
bool Draft = false);
./**/*.mdfindsgetting-started.mdand also<slug>/index.md, so a post can keep its images beside it.Slugcomes from the file name, or the folder name forindex.md.[Unique]fails the build when two posts share one.[Reference("Authors")]turnsauthorId: khalidin the front matter into a fullAuthor.[GroupBy…]builds tag, category and month datasets. See Tags and archives.RawMarkdownholds the post body. Bevel does not render Markdown. You do, in a component.WordCountandReadingMinuteshave defaults, so front matter does not have to supply them. A processor fills them.
A post file looks like this:
---
title: Getting Started with Bevel and ASP.NET Core
date: 2026-11-25
authorId: khalid
summary: How Bevel turns build-time data and Razor components into static HTML pages.
tags: [aspnetcore, bevel, razor]
category: Guides
featured: true
contributors: [ada]
---
You shouldn't have to leave ASP.NET Core to build a static site.
Authors and site settings
Smaller datasets sit next to the posts. Data/Authors/authors.json fills data.Authors, and Data/Site/site.yaml fills a single data.Site object with the title, description and baseUrl. A root array in a file makes a list. A root object makes one item.
Drafts and build-time work
A processor changes posts while Bevel builds the data. The sample uses three. One removes drafts, one pulls the first paragraph, and one counts words.
public sealed class DropDrafts(IHostEnvironment env) : IProcessor<BlogPost>
{
public ProcessResult<BlogPost> Process(BlogPost post)
=> post.Draft && !env.IsDevelopment() ? ProcessResult.Remove : post;
}
Routes
You declare every URL in Program.cs, once.
// 1. Single static Razor pages
// Home is a paged collection: page 1 is served at "/", the rest at /page/{PageNumber}.
app.MapStaticPaged<HomePage>("/page/{PageNumber}", (ISiteData data) => data.Posts,
pageSize: 3, mapFirstPageAtRoot: true);
app.MapStatic<AboutPage>("/about");
app.MapStatic<ReleasesPage>("/releases");
app.MapStatic<NotFoundPage>("/404.html");
// 2. One page per item. The item type comes from the delegate's return type and flows into the page's
// typed [Parameter]; route tokens bind to item properties.
app.MapStatic<PostPage>("/posts/{Slug}", (ISiteData data) => data.Posts);
app.MapStatic<TagPage>("/tags/{Slug}", (ISiteData data) => data.Posts.Tags);
app.MapStatic<CategoryPage>("/categories/{Slug}", (ISiteData data) => data.Posts.Categories);
app.MapStatic<ArchivePage>("/archive/{Slug}", (ISiteData data) => data.Posts.Archive);
MapStaticPagedserves page 1 at/and the rest at/page/{PageNumber}.MapStatic<PostPage>("/posts/{Slug}", ...)makes one page for each post.{Slug}binds to the item'sSlug.- Tag, category and archive pages come from the group datasets.
Render the Markdown
The post page hands RawMarkdown to a Markdown component. The component parses with Markdig once, and the table of contents and body share that result, so heading ids always match. See Markdown extensions for the pipeline.
Images in a post folder are served and exported with an asset folder:
options.AssetFolders.Add(new("Data/Posts", "/posts", "*.png", "*.jpg", "*.svg", "*.webp"));
Only files that match a pattern are published. index.md is never served.
Feeds, sitemap and search
Routes that are not pages return BevelResults.Xml(...) or BevelResults.Json(...). The sample writes /rss.xml, /sitemap.xml and /search-index.json this way. SyndicationBuilder.cs builds the two XML files. For the search file, see Search your site.
Export and deploy
dotnet run -c Release --project samples/Bevel.SampleBlog -- --bevel-build
The sample exports into its wwwroot folder. Deploy that folder to any static host. See CLI and environment for output folders.