1. Create the site

Create an ASP.NET Core app, add Bevel, load a site settings file, and render a home page.

On this page
bash
mkdir Bevel.Conference && cd Bevel.Conference
dotnet new web -n Bevel.Conference -f net10.0 -o .
dotnet add package Bevel

By the end of this step you have a home page that shows your conference name, date, city and tagline. All of it comes from a settings file.

  1. Write the settings file

    Bevel loads files under Data/ at build time. Create Data/Site/site.yaml:

    samples/Bevel.Conference/Data/Site/site.yamlyaml
    title: Bevel Conf 2027
    tagline: Two days of static sites, written in C#.
    description: A fictional conference for .NET developers who like their sites fast, simple and built with Razor.
    city: Lisbon
    timeZone: Europe/Lisbon
  2. Describe it with a record

    Create Data/Site/SiteConfig.cs. The attribute names the dataset (Site) and points at the file. The path is relative to this .cs file:

    samples/Bevel.Conference/Data/Site/SiteConfig.cscsharp
    namespace Bevel.Conference.Data;
    
    [DataSource("Site", "./site.yaml")]
    public sealed record SiteConfig(
        string Title,
        string Tagline,
        string Description,
        string City,
        string TimeZone);

    When you build, Bevel generates ISiteData with a Site property of type SiteConfig. The compiler now knows every setting you have.

  3. Add a layout

    Create Components/MainLayout.razor. It holds the <html> shell that every page shares:

    Components/MainLayout.razorrazor
    @inherits LayoutComponentBase
    @inject ISiteData Data
    @inject ISiteLinks Links
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="utf-8"/>
      <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
      <meta name="description" content="@Data.Site.Description"/>
      <link rel="stylesheet" href="@Links.Asset("/css/site.css")"/>
      <SectionOutlet SectionName="head"/>
    </head>
    <body>
    <header class="site-header">
      <a class="brand" href="@(Links.To<HomePage>())">Bevel Conf <span>2027</span></a>
    </header>
    <main>
      @Body
    </main>
    <footer class="site-footer">
      <p>@Data.Site.Title · @Data.Site.City · Made with <a href="https://github.com/khalidabuhakmeh/bevel">Bevel</a></p>
    </footer>
    </body>
    </html>

    Links builds URLs. Links.Asset adds your path base to a file such as the stylesheet. Links.To<HomePage>() finds the URL of a page from its route.

  4. Add the imports

    Create _Imports.razor in the project root so every component sees the same namespaces:

    _Imports.razorrazor
    @using Microsoft.AspNetCore.Components
    @using Microsoft.AspNetCore.Components.Web
    @using Microsoft.AspNetCore.Components.Sections
    @using Bevel
    @using Bevel.Conference
    @using Bevel.Conference.Data
    @using Bevel.Conference.Components
    @using Bevel.Conference.Pages
  5. Add the styles

    Copy wwwroot/css/site.css from the sample into your wwwroot/css/ folder. It is 51 lines of plain CSS. You do not need to read it.

  6. Write the home page

    Create Pages/HomePage.razor:

    Pages/HomePage.razorrazor
    @layout MainLayout
    @inject ISiteData Data
    
    <SectionContent SectionName="head">
      <title>@Data.Site.Title</title>
    </SectionContent>
    
    <section class="hero">
      <p class="eyebrow">May 12–13, 2027 · @Data.Site.City</p>
      <h1>@Data.Site.Title</h1>
      <p class="lead">@Data.Site.Tagline</p>
    </section>
  7. Map it

    Replace Program.cs. AddBevel turns Bevel on. MapStatic says "this page lives at this URL":

    Program.cscsharp
    using Bevel.Conference.Pages;
    
    var builder = WebApplication.CreateBuilder(args);
    builder.AddBevel();
    
    var app = builder.Build();
    
    app.UseStaticFiles();
    
    app.MapStatic<HomePage>("/");
    
    app.Run();

    UseStaticFiles serves your stylesheet while you run the site live.

Run it

bash
dotnet watch

Open the URL it prints. You should see the page below: the conference name, a tagline, and nothing else yet.

A cream-colored page with the Bevel Conf 2027 logo, a date and city line, a large title and the tagline Two days of static sites, written in C#.
Step 1: a home page driven by site.yaml.

Change tagline in site.yaml and save. The page updates. That is the whole loop: edit a file, see a page.

Next: 2. Speakers from YAML.