Build and deploy a Statiq site to Github Pages in 5 min

Friday, 23 September 2022
Statiq dotnet GitHub Pages Static Site Generator
Edit This Page

A step by step walk through on how to create a Statiq site and deploy it to GitHub Pages.

Video walk through


git (winget install Git.Git) GitHub CLI (winget install GitHub.cli) dotnet 6.0 (winget install Microsoft.DotNet.SDK.6)

You will need a GitHub Account.

Step by step

Login to gh

gh auth login

Follow the prompts.

Create the repo

gh repo create statiq-github-pages --public --gitignore VisualStudio

Enable GitHub pages

  1. Open your newly created repo in the browser

    gh repo view statiq-github-pages --web
  2. From the horizontal navigation bar select "Settings"

  3. On the left choose Pages

  4. Select "GitHub Actions" as the "Build and deployment" "Source"

  5. Select Configure next to "Static HTML" for the workflow.

  6. Update the pages.yaml as follows:

    # Simple workflow for deploying static content to GitHub Pages
    name: Deploy static content to Pages
      # Runs on pushes targeting the default branch
        branches: ["main"]
      # Allows you to run this workflow manually from the Actions tab
    # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
      contents: read
      pages: write
      id-token: write
    # Allow one concurrent deployment
      group: "pages"
      cancel-in-progress: true
      # Single deploy job since we're just deploying
          name: github-pages
          url: ${{ steps.deployment.outputs.page_url }}
        runs-on: ubuntu-latest
          - name: Checkout
            uses: actions/checkout@v3
          - name: generate statiq site
            uses: actions/setup-dotnet@v1
              dotnet-version: '6.0.401'
          - run: dotnet run --project ./MyGenerator/MyGenerator.csproj
          - name: Setup Pages
            uses: actions/configure-pages@v2
          - name: Upload artifact
            uses: actions/upload-pages-artifact@v1
              # Upload entire repository
              path: './MyGenerator/output'
          - name: Deploy to GitHub Pages
            id: deployment
            uses: actions/deploy-pages@v1
  7. Select Start commit near the top right

  8. Then choose Commit new file

GitHub Pages is now enabled and will automatically update as commits are merged into the master/main branch.

Return to the console for next steps

Clone the git repo

gh repo clone statiq-github-pages
cd .\statiq-github-pages\

Write the dotnet project

  1. create new console app

    dotnet new console -n MyGenerator
    cd .\MyGenerator\
  2. Add the Statiq.Docs Nuget package

    dotnet add package Statiq.Docs --version 1.0.0-beta.5
  3. Edit Program.cs to contain the following:

await Bootstrapper
  1. Create input folder

    mkdir input
  2. Create in the input folder as

    Title: My First Statiq page
    # Hello World!
    Hello from my first Statiq page.
  3. add, commit and push

    git add --all
    git commit -m "My Statiq Github pages site"
    git push


Browse to the published site.


Dream Studio AI was used to generate the cover image.