Website updates 2020

Current events have given me a lot of time in the evenings to catch up on side projects, one of which was an update of this website. I'd been wanting to do this for a while, but pretty much since mid-2019 had been too busy. For the last month or so I have been overhauling it behind the scenes and the end result is now live.

Static site builders

Initially I built this site with Jekyll, but eventually grew tired of some of the boundaries I had to work within:

GitHub Pages is able to host any static files in the repo's master branch, so I could just add HTML files built by hand or any static site builder. After a look at Jekyll alternatives, I asked myself the same question that any sane, well-adjusted programmer does: how hard can it be to just roll my own? I figured that if I could build a combination of Markdown processing, HTML templating and post metadata handling, not only would I be able to pare it down to just the bits I needed, it would also be an interesting learning experience. The result is about 450 lines of site building code using Python-Markdown, Jinja2 and Pygments.

Simpler CSS

I was also initially doing styling with Bootstrap, which is used for many large web projects but I've found it to be overkill for small static sites. The source code of Bootstrap's CSS base runs to over 10,000 lines even before adding Javascript interactivity. The heavy use of CSS classes and the verbose and repetitive language necessary for defining even something like a small navbar was starting to get to me:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">A navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar_content" aria-controls="navbar_content" aria-expanded="false" aria-label="Toggle nav">
<span class="navbar-toggler-icon"></span>
</button>
 
<div class="collapse navbar-collapse" id="navbar_content">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">This</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">That</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Other</a>
</li>
</ul>
</div>
</nav>

So at the same time as building my own static site generator, I was looking at alternative CSS frameworks. While writing the site builder happened fairly naturally, I spent a lot of time puzzling over how I wanted to style it. I wanted something relatively lightweight but still responsive and mobile-friendly. I'm also not hardcore enough to build a website style from scratch, so I was fine with the framework being 'opinionated' and guiding you towards doing things a certain way. After trying a few frameworks and CSS resets, I decided on Picnic, which has a responsive grid system but is otherwise relatively classless. This means that the HTML for defining a navbar is a bit nicer:

<nav>
<a href="#" class="brand">A Navbar</a>
<input id="minimenu" type="checkbox" class="show">
<label for="minimenu" class="burger pseudo button"><img class="icon_large" src="/img/menu.svg" /></label>
 
<div class="menu">
<a href="#">Home</a>
<span class="divider"></span>
<a href="#">This</a>
<a href="#">That</a>
<a href="#">Other</a>
</div>
 
</nav>

This then is a two-part exercise in minimalism - my own small rebellion against the endless DOM tree nesting, Javascript dependencies, myriad UI frameworks and other excesses of modern web development.

While I'm happy with the result, there are still some improvements I can make. The new site's workflow is definitely not as polished as Jekyll's at the moment. The built files have to sit in master, so the source files have to be somewhere else in a separate branch or repo. This means that whenever I want to update the site, I have to push changes twice. This may or may not be fixable - on the face of it, GitHub Pages seems to be fairly tightly integrated with Jekyll and there's no documentation on how to use anything other than Jekyll, but it may be possible to streamline the process with TravisCI. I'll see if I can get that to work later.

External links