Quickstart

Create a Bevel site from a template, run it live, and export static HTML in five minutes.

On this page
bash
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

  1. Install the templates Since 0.2

    You install them once.

    bash
    dotnet new install Bevel.Templates
  2. Create a site

    Use bevel for a minimal site, or bevel-blog for a blog with sample posts.

    bash
    dotnet new bevel -n MySite     # or: dotnet new bevel-blog -n MyBlog
    cd MySite
  3. Run it live

    dotnet watch renders pages on demand and reloads when you edit.

    bash
    dotnet watch

    Open the URL it prints. You see your home page.

  4. Export it

    bash
    dotnet run -c Release -- --bevel-build

    The app binds no port and exits when it is done. You find index.html in wwwroot/.

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.

  1. Create an app

    bash
    mkdir MySite && cd MySite
    dotnet new web -n MySite -f net10.0 -o .
    dotnet add package Bevel
  2. Add data

    Bevel loads anything under Data/ at build time. Create Data/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 .cs file:

    Data/Site/SiteInfo.cscsharp
    namespace MySite.Data.Site;
    
    [DataSource("Site", "./site.json")]
    public sealed record SiteInfo(string Title);

    When you build, Bevel generates an ISiteData interface with a Site property of type SiteInfo.

  3. Add a page

    Create _Imports.razor in the project root:

    _Imports.razorrazor
    @using Microsoft.AspNetCore.Components.Web
    @using Bevel

    Then 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>
  4. 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();
  5. Run it

    bash
    dotnet run

    Open the URL it prints. In the Development environment the page renders live. Edit HomePage.razor or site.json, rebuild (or use dotnet watch), and refresh.

  6. Export it

    bash
    dotnet run -- --bevel-build

    Bevel renders every mapped page and writes wwwroot/index.html. The app binds no port and exits when it is done. Copy wwwroot to any static host. Bevel also writes wwwroot/.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:

samples/Bevel.Conference/Program.cscsharp
// 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.