Metalsharp 1.1.0

dotnet add package Metalsharp --version 1.1.0
                    
NuGet\Install-Package Metalsharp -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Metalsharp" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Metalsharp" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Metalsharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Metalsharp --version 1.1.0
                    
#r "nuget: Metalsharp, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Metalsharp@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Metalsharp&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Metalsharp&version=1.1.0
                    
Install as a Cake Tool

<div align="center">

<img src="https://raw.githubusercontent.com/IanWold/Metalsharp/refs/heads/master/Icon.png" height="23"> Metalsharp

NuGetNuGet Downloads

A tiny and extendable static site generator for C#, inspired by Metalsmith.

Quickstart • Plugins • Examples

</div>


Generating a static website from a directory is as simple as this:

new MetalsharpProject()
    .AddInput("Site")
    .UseFrontmatter()
    .UseMarkdown()
    .AddOutput("Static")
    .Build();

Metalsharp is:

  1. Small — uses the smallest amount of code necessary to get the job done,
  2. Simple — straightforward API with easy-to-understand documentation, and
  3. Extendable — creating and publishing plugins is as easy as possible.

Getting Started

Metalsharp targets .NET 10 and is available on NuGet:

dotnet add package Metalsharp

Prefer to try it without setting up a project? Metalsharp works great with .NET file-based apps — see the Create a Website tutorial for a walkthrough that builds a complete site with nothing but a single .cs file.

Project Structure

A Metalsharp project doesn't require any particular directory layout, but the following structure works well for most sites:

ProjectFolder
├── Site
│   ├── SomeFile.md
│   └── SomeOtherFile.md
├── Static
│   └── style.css
└── README.md

Here, ProjectFolder is the root of the project. Anything unrelated to the generated site — your build script, README, and so on — can live at this level. Content that Metalsharp will process goes in Site, and files that should be copied straight through to the output, such as stylesheets and images, go in Static. Neither of these directory names is a requirement; use whatever structure fits your project.

Using Metalsharp

Let's walk through the example above. The quickstart covers the basics in more depth, and Create a Website with Metalsharp walks through a complete, practical project.

  1. Instantiate a MetalsharpProject and read in the files you want to work with:

    new MetalsharpProject()
        .AddInput("Site")
    
  2. Invoke a plugin by passing an instance to Use. Frontmatter reads each file's frontmatter into its metadata:

    .Use(new Frontmatter())
    
  3. If a plugin has a public parameterless constructor, you can reference its type instead:

    .Use<Frontmatter>()
    
  4. Most of the plugins that ship with Metalsharp — Frontmatter included — also provide an extension method that does the same thing, for convenience:

    .UseFrontmatter()
    
  5. Markdown works the same way; it converts Markdown files in the input into HTML files in the output:

    .UseMarkdown()
    
  6. Add any files that should be copied straight through to the output, such as static assets:

    .AddOutput("Static")
    
  7. Finally, call Build to write the output files to disk:

    .Build();
    

Creating a Custom Plugin

Creating a Metalsharp plugin is straightforward — see Create a Plugin for Metalsharp for a full walkthrough. At its core, a plugin only needs to implement IMetalsharpPlugin, which has a single method, Execute. Here's the Markdown plugin that ships with Metalsharp:

public class Markdown : IMetalsharpPlugin
{
    public void Execute(MetalsharpProject project)
    {
        foreach (var file in project.InputFiles.Where(f => f.Extension is ".md" or ".markdown"))
        {
            var fileText = Markdig.Markdown.ToHtml(file.Text);
            var filePath = Path.Combine(file.Directory, file.Name + ".html");

            project.LogDebug($"Converting Input file {file.FilePath} to Output file {filePath}");

            project.OutputFiles.Add(new MetalsharpFile(fileText, filePath)
            {
                Metadata = new Dictionary<string, object>(file.Metadata)
            });
        }
    }
}

Docs

The wiki contains generated API reference documentation and hand-written tutorials.

The source is fully documented with XML comments. The API docs on the wiki are generated from those comments by GenerateApiDoc.cs.

Contributing

Contributions are welcome in whatever form suits you — bug reports, documentation fixes, new plugins, or pull requests against the core library.

License

Metalsharp is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Metalsharp:

Package Downloads
Metalsharp.LiquidTemplates

A Metalsharp plugin that applies Liquid templates, via Fluid, to a static site's HTML output.

Metalsharp.SimpleBlog

Plugin for Metalsharp providing a barebones blog implementation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 80 11/14/2026
1.0.1 301 8/12/2026
1.0.0 126 8/11/2026
0.9.0-rc.6 1,394 11/3/2024
0.9.0-rc.5 1,444 8/15/2022
0.9.0-rc.4 291 8/15/2022
0.9.0-rc.3 256 8/15/2022
0.9.0-rc.2 273 8/10/2022
0.9.0-rc.1 639 12/14/2018