Beckshome on Statiq

Published on Saturday, 10 September 2022

After 7 years of being dormant, the beckshome.com blog hummed back to life over the past month. It started with a full .NET hosted blog, moved to Wordpress and then was exported from Wordpress to create static content in 2015, which is where things stood for the past 7 years. I decided to go with a static site generator to modernize the site, specifically with Statiq, which is a .NET-based static site generator.

Once you get beyond the Hello World examples of getting Statiq stood up, there's a lot of work to be done to get a blog ported over. Some of this work is brute force conversion of years of blog posts into Markdown format. Some of it lies in the details of Statiq configuration. Rather than reinventing the wheel on this latter topic, I point to a great blog post on migrating to Statiq along with two GitHub repositories containing Open Sourced versions of live Statiq sites -- from Alexandre Nédélec and from David Glick, the creator of Statiq. I have also made my blog's repository on GitHub public.

There are several lessons I learned beyond what is in the aforementioned blogs. I have highlighted and documented these items below:

Post Destination Paths

The Clean Blog site theme documentation provides an example of using the _directory.yml file in the posts folder to output posts with computed, date-specific paths. The provided example does the trick for date-specific paths but still handles .MD path extensions. My changes below take care of both the date-based paths and .MD extension handling.

DestinationPath: => $"{Document.GetDateTime("Published").ToString("yyyy/MM")}" + "/" + $"{Document.Destination.FileName}".Replace(".md", "") + ".html"

Rewrite Rules for Hosting on Azure App Services

To get the Restful Url routing working and mask the HTML file extension required a custom rewrite rule in a web.config file. Surprisingly, I needed to put in a rule and a custom MIME extension for RSS as well. Very App Service / IIS specific but necessary if you're using these platforms.


  
    
      
    
    
      
        
          
          
        
        
          
          
            
            
          
          
        
      
    
  

Google Analytics

If you're looking to add Google Analytics, or other web tracking products, this is really simple in Statiq. Add the Google Analytics javascript to the _head.cshtml file, which should be blank, and go to town.




Giscus Commenting

Adding giscus commenting is as easy as dropping some Javascript into the _post-footer.cshtml file. You can generate the specific javascript on the giscus site or replace the fillers below.


Sidebar Social Links

Adding the social links below the tags in the sidebar is a two-step process. First, add a reference to the social-links partial in the _sidebar.cshtml file.

@Html.Partial("_social-links")

And then adding the following details into the _social-links.cshtml file with your specific links.