StatiCSharp 0.5.0

dotnet add package StatiCSharp --version 0.5.0                
NuGet\Install-Package StatiCSharp -Version 0.5.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="StatiCSharp" Version="0.5.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StatiCSharp --version 0.5.0                
#r "nuget: StatiCSharp, 0.5.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.
// Install StatiCSharp as a Cake Addin
#addin nuget:?package=StatiCSharp&version=0.5.0

// Install StatiCSharp as a Cake Tool
#tool nuget:?package=StatiCSharp&version=0.5.0                

Welcome to StatiC#, a static website generator for C# developers. It enables entire websites to be built using C#. Custom themes can be used by editing the integrated default theme or importing a theme.


StatiC# provides everything you need to create a website with all the files needed to upload onto a web server.

If you want to quickstart with your new website, you can start with the default configuration and build up from there. You can find a template in the documentation.
Here is an example:

using StatiCSharp;

var myAwesomeWebsite = new Website(
    url: "https://yourdomain.com",
    name: "My Awesome Website",
    description: @"Description of your website",
    language: "en-US",
    sections: "posts, about"            // Select which folders should be treated as sections
);

var manager = new WebsiteManager(
    website: myAwesomeWebsite,
    source: @"C:\path\to\your\project"  // Absolute path to your Content, Resources and Output directories.
);

await manager.Make();

Add StatiC# to your project

To get started, create a new console application at a path of your choice. Let's say that your new website is called myWebsite:

$ dotnet new console -n myWebsite

After .NET has created the project files open myWebsite.csproj and add StatiC# as a package reference. The file should then look something like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="StatiCSharp" Version="0.5.0" />
  </ItemGroup>

</Project>

Then you can get started using StatiC# by importing it at the beginning of your Program.cs:

using StatiCSharp;

Quick start

You can use StatiC#'s project template to quick start or follow the following steps to set up your project manually.
Nevertheless it's recommended to read this readme to get a understanding how StatiC# works.

StatiC# expects three folders to work with at the path given during the initialization of the WebsiteManager.

Content: This folder contains the markdown files that our website depents on.
Output: Here the final website with all the necessary files will be saved.
Resources: Put all your static files in here. All files will be copied, without any manipulation, to the output. Folders are migrated.

I recomment to put those folders within your project folder of myWebsite. Your folder should look something like this:

├── myWebsite
│   ├── Content
│   ├── Outout
│   ├── Resources
│   ├── myWebsite.csproj
│   ├── Program.cs
│   ├── styles.css

StatiC# renders four different types of sites:

index: The homepage of your website
pages: Normal sites e.g. your about page.
sections: Sites that contain items e.g. articles in a specific field.
items: The sites that are part of a section.

Add some content to your website by adding your markdown files to the Content folder. Check out the documentation for a template file:

├── myWebsite
│   ├── Content
│   │   ├── index.md                    // This is your homepage.
│   │   ├── posts                       // Contains all items for the posts section.
│   │   │   ├── index.md                // Content of the section site.
│   │   │   ├── your-first-post.md      // Item within the posts section.
│   │   │   ├── your-second-post.md     // Another item within the posts section.
│   │   ├── about                       // Contains a page.
│   │   │   ├── index.md                // Content of the about page.
│   │   │   ├── another-page.md         // Content of another page.
│   ├── Outout
│   ├── Resources
│   ├── myWebsite.csproj
│   ├── Program.cs

Store your content in folders and StatiC# cares about the rest. All folders are treated as pages unless their name is used to build a section.

Finally set up the parameters in Program.cs in your myWebsite project:

using StatiCSharp;

var myAwesomeWebsite = new Website(
    url: "https://yourdomain.com",
    name: "My Awesome Website",
    description: @"Description of your website",
    language: "en-US",
    sections: "posts, about"            // Select which folders should be treated as sections.
);

var manager = new WebsiteManager(
    website: myAwesomeWebsite,
    source: @"C:\path\to\your\project"  // Absolute path to your Content, Resources and Output directories.
);

await manager.Make();

Run the project and your new awesome website will be generated in the Output directory:

$ dotnet run

Check out the documentation for further information.

Dependencies

Contributions and support

StatiC# is developed completely open, and your contributions are more than welcome.

Before you start using StatiC# in any of your projects, please have in mind that it’s a hobby project and there is no guarantee for technical correctness or future releases.

Since this is a very young project, it’s likely to have many limitations and missing features, which is something that can really only be discovered and addressed as you use it. While StatiC# is used in production on my personal website, it’s recommended that you first try it out for your specific use case, to make sure it supports the features that you need.

If you wish to make a change, open a Pull Request — even if it just contains a draft of the changes you’re planning, or a test that reproduces an issue — and we can discuss it further from there.

I hope you’ll enjoy using StatiC#!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
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 StatiCSharp:

Package Downloads
StatiCSharp.Theme.Foundation

A custom theme for StatiC#, a static website generator for C# developers.

StatiCSharp.Parser.CSharpToColoredHtml

This is a port of Swiftly1's CsharpToColouredHTML for StatiC#, a static website generator for C# developers. C# code parts of your markdown files are rendered to look as if it was inside Visual Studio or Visual Studio Code.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.0 606 12/3/2023
0.4.1 703 4/6/2023
0.4.0 891 1/16/2023
0.3.0 968 12/22/2022
0.2.0 1,375 9/3/2022
0.1.1 1,093 8/14/2022

This release brings the upgrade to .NET 8.