Get started

SSG.NET has the goal of allowing ASP.NET Core MVC developers to generate static (client-side only) web applications, while allowing them to reuse the concepts and tools they are already familiar with: Partial Views, Tag Helpers, Layouts, and so on.

This should facilitate using free/cheap hosting without forcing developers to learn JavaScript SPA frameworks, but also without forcing them to handle individual HTML files which would require them to duplicate a lot of code.

Using SSG.NET is as simple as developing your ASP.NET Core MVC website (while keeping in mind the restrictions mentioned below), followed by running the SSG through the console, either manually or in some automated pipeline.

SSG.NET works by running your application's Views directly through ASP.NET Core internals in a process similar (but greatly simplified) to what happens when you run your application.

SSG.NET is free, Open-Source Software, and you can use it for any personal/commercial purposes, under the conditions of the MIT license .

Installation

Installing SSG.NET can be done via the dotnet tool CLI:

dotnet tool install --global TerevintoSoftware.StaticSiteGenerator.Tool

Features

1. Route casing

SSG.NET supports 3 route casing strategies: kebab casing the URLs, lower casing the URLs, and keeping the original route.

With kebab casing, SSG.NET will transform URLs such as /Blog/SomeLongName into /blog/some-long-name and will accomodate numbers based on the original case: Abc2A => abc2-a; A2bc => a2bc; 2Abc => 2-abc; etc.


2. Localization

Localization is known to work (and officially supported) through view file localization, in other words: Index.cshtml, Index.es.cshtml, and Index.fr.cshtml would generate 3 different HTML files.

Other types of localization, such as through the @Microsoft.AspNetCore.Mvc.Localization.I*Localizer classes may or may not work, and need testing.


3. Blog template

While not a part of SSG.NET per se, we provide a fully functional blog template ready to be consumed as a GitHub template repository . This application supports:

  • MarkDown support
  • Automatic RSS and SiteMap creation
  • Post management
  • SEO and social media meta tags

Command Line

The following options are supported by SSG.NET:
  • Argumentthe path to the folder that contains the project to generate the static site for.
  • -o|--output: the path to the output directory (write permissions needed).
  • -a|--assembly: the path to the assembly to use for the project. Defaults to the Release or Debug build of the target framework of the project, if found.
    If given, the value must point to the compiled .dll.
  • --base-controller: the name of the base controller to use for the project.
  • --route-template: the default route template to use for the project.
  • --route-casing: the casing convention to use for routes.
  • --default-culture: the default culture to use for the project.
  • --use-localization: whether to enable localization for the project.
  • --clear-output: whether to delete the output folder, if it exists.
  • --verbose: enables verbose logging.
  • --version: shows the version of the package installed.
Sample usage

This site is built using SSG.NET and is built through a GitHub Action, using the following options, and published (for free!) to Netlify :

ssg generate ./src/TerevintoSoftware.StaticSiteGenerator.Demo -o /out --route-casing KebabCase --use-localization true

Limitations

Tests have so far proven that the following work:
  • Views
  • Partial views/Tag helpers
  • File suffix-based localization
Controllers/Models/Middleware/etc are, obviously, unsupported as this the code is transformed into HTML. Areas and View Components might work but have not been tested. Razor Pages are unsupported but support could be provided if help is given.

Improving SSG.NET

If you want to help, you can do so by:
  1. Helping out with this site, such as improving design or adding more translations.
  2. Adding more unit/integration tests.
  3. Proposing features/bug fixes/etc.