tdarb.org > My Static Blog Publishing Setup: Part 2

// 399 words // 2 minute read

My Static Blog Publishing Setup: Part 2

A couple weeks ago I updated my blog publishing workflow and wrote about it. Since then, I've made some very minor changes to make my life slightly easier. (Don't worry, everything is still static HTML!)

Using Server Side Includes

I've worked with Server Side Includes (SSI) throughout my career but never had the ability to use them on my personal website since I previously used static-based hosting providers (Digital Ocean Apps, Netlify, Github Pages). Now with my recent switch over to NearlyFreeSpeech, I have the ability to use SSI!

Although I have the option to rely on SSI, I never want to depend so heavily on such a feature. My implementation simply includes three main sections to avoid running into DRY conflicts:

For each section I needed to create a custom .shtml "template" file, like so:

These files are placed in the root directory of my web server and called into each page that requires them using HTML comments:

<!--#include virtual="/_head.shtml" -->

Nothing too fancy.

Setting Up SSI

If you're interested in using SSI on your own server, it is fairly easy to setup. In your .htaccess file (create one in your root directory if it does not exist yet) and paste the following near the top of the file:

AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
AddHandler server-parsed .html .htm

Now you can create as many "template" include files as you like! Just be sure to name their extensions as .shtml. There are ways to setup SSI to except standard .html files as includes, but I prefer to keep SSI files visually separate by using different extensions.

To include any of your template files, you need to add the proper HTML comment to the page (as I referenced above). Just remember the virtual URL PATH used needs to be relative to the files / current directory - not absolute.

Example:

<!--#include virtual="/your-awesome-include.shtml" -->

Still Static HTML

Although using SSI may seem more dynamic, everything is still created directly in HTML from my end. I feel like this is more helpful than needing to solely rely on "Find and Replace" actions in an editor.


Leave a comment

To make a comment, please send an e-mail using the button below. Your e-mail address won't be shared and will be deleted from my records after the comment is published. If you don't want your real name to be credited alongside your comment, please specify the name you would like to use. If you would like your name to link to a specific URL, please share that as well. Thank you.

Comment via email

Comments (6)
  1. joelchrono12
    Who would have thought servers came with their own static site generating shenanigans %)

    BTW I was wondering how do you know when something is *italics* or **bold** in plain text? Or do you just follow the Markdown syntax? As far as I know, using /this/ meant italics back in the day, but I wasn't there to see it.

    • Bradley Taunt
      Good question! As you can see, I currently just leave the styling "characters" alongside the content. I've also removed the formatting text to avoid confusion 😛

  2. Barry Hess
    Thanks for sharing your HTML-site journey! I think I'll be going on one as well.

    Server Side Includes bring me way back to the beginning of my web-programming experience. It surprises me that none of these providers (RE: GitHub or Vercel or Cloudflare) are supporting SSIs. It'd be great if there is a hosting service out there who both auto-deploys from GitHub _and_ supports SSIs. Failing that, I'd love a top 10 of easyish options with SSI support to go alongside NearlyFreeSpeech.net.

    • Bradley Taunt
      Agree 100%. I wish they would even implement their own "limited" version of SSI, instead of needing to open up .htaccess file configurations etc. (if security is the main reason for avoiding them).

  3. Jw
    hi, I'm very interested in your html site setup as i'm a guy who don't code. I've only managed to use .php for includes. Is there any way to use variables as well using SSI? such as publish datetime, update time, etc. Also, is there a way to rewrite URLs like rewrite engine? isn't that a php thing? if so, could you please share? I did tries to search for it but to no avail.

    sorry for asking, I'm just too dumb...

    Anyway, thanks for sharing man. I'm Jw by the way. I blogged because of your post, here the link: https://fury.hk/blog/my-setup-for-this-blog

    • Bradley Taunt
      Hey @Jw, nice to e-meet you!

      Is there any way to use variables as well using SSI?

      Not that I am aware of off the top of my head. Something like that probably needs to be rendered at build time with a static site generator. Or your HTML pages need to have the ability to render PHP directly inside them.

      Also, is there a way to rewrite URLs like rewrite engine?

      You can achieve this on most hosting platforms via the .htaccess file (like I do for this website!)