A place to cache linked articles (think custom and personal wayback machine)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.md 2.9KB

title: Next Gen Static Blogging url: https://inoads.com/articles/2021-01-09-Next-Gen-Static-Blogging hash_url: 2458bbc9f8

2021-01-09 mmackhToggle Reader

TL;DR

Take a look at the source code of this page - I rely mostly on CSS for the rendering of this article.

The CSS property powering this article,

white-space: pre-line
, has existed since the IE8 days.

Background

My first programming exercise was to code a blog using PHP. Add text files to a folder via FTP, scan the directory and generate the HTML dynamically. How about adding an admin frontend? Or a database as a backend? All good and well, but when do you find the time to actually write your articles?

If it’s one thing I learnt over the past years of coding is that simplicity is key. You don’t need a lot of CSS or HTML Tags to make a page look pretty. It may not be the absolute correct way to do it, but look at the source code of this page. It’s tiny!

My Solution

Instead of nesting

<div>
after
<div>
or
<p>
to create paragraphs, I stumbled upon
white-space: pre-line
. To quote the MDN Web Docs - “Sequences of white space are collapsed. Lines are broken at newline characters, …” - and that is key. I use HTML tags like
<em>
or
<b>
for emphasis only.

Every paragraph is initiated with a newline character. The experience to writing this blog entry is very similar to using a dedicated word processor. Except you have much more control, more settings you can tweak and more visuals you can add.

A similar technology I can think of is Markdown. Except you have to run it through a parser before seeing the result. Also, different flavours produce different outputs. All rather messy for me. My workflow consists of pressing CMD+S, switching to Safari and reloading the page. What you see now is what I get.

Managing this blog is a little more involved than dynamically generating everything. The design could also be a little prettier.

More Benefits

The overall page size is tiny. No need for JavaScript or any other complicated backend or client-side frameworks. I can use PHP to introduce dynamic elements to the page, but that’s optional. Maybe you might be inspired a little and move your blog off centralised platforms like Medium, etc. and start embracing the simplicity of creating compelling pages with very little code. Simplicity is key.