Devlead.Statiq - Part 3 - IncludeCode 🤺

An .NET assembly extending the static site generator Statiq with new core features

Published on Sunday, April 11, 2021

So I'm lazy... when doing a blog post, or documentation I don't want to repeat my self, and a prime example of that is when documenting Statiq features I found my self to want to both display both the "source" and the "result" without having to type the same thing twice nor update in multiple places and that's why I created the IncludeCode Shortcode and in this last of the three-part introductory blog post series about the NuGet package Devlead.Statiq I'll tell you all about it.

IncludeCode Shortcode

Code include shortcode - A Statiq shortcode enables you fetch an external file into a markdown code fence block.

Statiq comes with a built in Include shortcode, which will just merge in the source of another document into the document utilizing the shortcode. This is really handy as it'll for example lets you edit content in one place, but you can use it in multiple places keeping things dry.

The issue and feature with Include is that it'll be executed as part of your Statiq App pipeline, any code in it will be rendered. Which might not be what you want for a code sample. So I created the IncludeCode shortcode which will process and include the external document within a markdown code fence.

Example usage

<?# IncludeCode "./../includes/posts/2021/devlead-statiq/includecode/src/HelloWorld.cs" /?>


public class HelloWorld
    public string Greeting { get; set; }


IncludeCode shortcode is a small addition, but it keeps my content DRY which I've learned to really appreciate as it not only reduces typing, but also reduces risk of inconsistencies and errors.