Quickstart
Create a Bevel site from a template, run it live, and export static HTML in five minutes.
On this page
dotnet new install Bevel.Templates
dotnet new bevel -n MySite
cd MySite
dotnet watch # live pages while you edit
dotnet run -c Release -- --bevel-build # static export into wwwroot/
That is the whole loop. You need the .NET 10 SDK first (see Install).
Create the site
Install the templates Since 0.2
You install them once.
bash dotnet new install Bevel.TemplatesCreate a site
Use
bevelfor a minimal site, orbevel-blogfor a blog with sample posts.bash dotnet new bevel -n MySite # or: dotnet new bevel-blog -n MyBlog cd MySiteRun it live
dotnet watchrenders pages on demand and reloads when you edit.bash dotnet watchOpen the URL it prints. You see your home page.
Export it
bash dotnet run -c Release -- --bevel-buildThe app binds no port and exits when it is done. You find
index.htmlinwwwroot/.
Template options
| Option | Templates | Meaning |
|---|---|---|
--site-title "My Site" |
bevel, bevel-blog |
Site title. Keep it JSON/YAML-safe: no double quotes or backslashes. |
--base-path /repo |
bevel, bevel-blog |
Sets BevelOptions.PathBase for hosting under a sub-path such as GitHub project pages. |
--no-sample-content |
bevel-blog |
Only one welcome.md starter post instead of the sample posts. |
Each template references the Bevel package version it shipped with. A GitHub Pages workflow option is planned. Until then, copy the workflow from 7. Ship to GitHub Pages.
You can also pick options with the command builder:
dotnet new bevel -n MySite
Set it up by hand
This walkthrough starts from nothing and ends with wwwroot/index.html. It is what the bevel template sets up for you. Replace MySite with your project name wherever it appears in a namespace.
Create an app
bash mkdir MySite && cd MySite dotnet new web -n MySite -f net10.0 -o . dotnet add package BevelAdd data
Bevel loads anything under
Data/at build time. CreateData/Site/site.json:Data/Site/site.jsonjson { "title": "My Site" }Next to it, create
Data/Site/SiteInfo.cs. The attribute names the dataset (Site) and points at the file, relative to this.csfile:Data/Site/SiteInfo.cscsharp namespace MySite.Data.Site; [DataSource("Site", "./site.json")] public sealed record SiteInfo(string Title);When you build, Bevel generates an
ISiteDatainterface with aSiteproperty of typeSiteInfo.Add a page
Create
_Imports.razorin the project root:_Imports.razorrazor @using Microsoft.AspNetCore.Components.Web @using BevelThen create
Pages/HomePage.razor:Pages/HomePage.razorrazor @inject ISiteData Data <html> <head><title>@Data.Site.Title</title></head> <body><h1>@Data.Site.Title</h1></body> </html>Map the page
Replace
Program.cs:Program.cscsharp using MySite.Pages; var builder = WebApplication.CreateBuilder(args); builder.AddBevel(); var app = builder.Build(); app.MapStatic<HomePage>("/"); app.Run();Run it
bash dotnet runOpen the URL it prints. In the Development environment the page renders live. Edit
HomePage.razororsite.json, rebuild (or usedotnet watch), and refresh.Export it
bash dotnet run -- --bevel-buildBevel renders every mapped page and writes
wwwroot/index.html. The app binds no port and exits when it is done. Copywwwrootto any static host. Bevel also writeswwwroot/.bevel-output.json, a manifest of the files it wrote. You can leave it out of your upload.
Host it under a sub-path
GitHub project sites live at https://you.github.io/repo/. Set PathBase and every link and asset follows. This is a real snippet from the conference sample:
// Hosted under a sub-path (GitHub Pages project sites)? Set it here and every link and asset follows.
// Pass it from the environment so the same code works locally and in CI: BEVEL_PATH_BASE=/bevel-conf
builder.AddBevel(options =>
{
options.PathBase = Environment.GetEnvironmentVariable("BEVEL_PATH_BASE") ?? "";
// The origin of the published site. The calendar feed needs it for absolute session URLs.
options.SiteUrl = Environment.GetEnvironmentVariable("BEVEL_SITE_URL") ?? "https://example.com";
});
See BevelOptions.PathBase for the rules.
Next
Build something bigger in Your first site, or learn how the pieces fit in How Bevel works. When you are ready to publish, read 7. Ship to GitHub Pages.