Static Site Generation with blogc

Introduction

Up until now I’ve been working on my sites in pure HTML; the only tool I used had been ssg to convert the little “wiki” I put op on GitHub to HTML and use it on my website.
Creating a HTML file every time I wanted to post something on my website is not a viable alternative, though, which is why I was looking for an option to make my life easier. I decided to ask people on the webring thread on lainchan for advice on how to set up a proper workflow for web development, as I am completely new to this.
The nice guy from concealed.world helped me get some ideas, which ultimately led me to blogc, the static site generator which I’m going to talk about here.

Why I chose blogc

Blogc is simple yet powerful. On their website they state it should be used with a tool like make. It’s not supposed to be a blogging engine but a compiler.
I like this approach, as I am a fan of C (programming language). To be perfectly honest, I don’t have all that much knowledge about make, but I want to learn, and this is part of the reason I’m making this website.

Starting out

To start, I downloaded the test repo they have up on GitHub (https://github.com/blogc/blogc-example) so that I don’t have to figure out everything by myself, as this could also be seen as a piece of documentation.
From there, I started changing my own template.html I had to function as a blogc template. If you want to follow this a bit, have a look at my repo and compare it with the example repo blogc provides.

Template

So far the template is really simple. As I said, I took the template.html I had and changed it to resemble a blogc template. The title is now set per page, copied from the template from the example repository. The links in the navbar are changed so it’s easier to change them, should I ever get another domain.
The main section is now filled with template things. I won’t go into detail, because the man page blogc-template goes into enough detail. It’s essentially just pasting the content of the source file in between the main tags.

Makefile

Writing the Makefile was a difficult thing for me. Every time I have to write one I need to skim through the documentation again to get stuff done.
Trying to imagine how my site should function with software I’ve never used before is also hard to do.
As I said before, you can find everything, including the Makefile, on my GitHub page.
I also took some inspiration for my Makefile from the example repo. A lot of the variables are taken straight from their Makefile, with values changed, obviously. I removed everything I didn’t need, which included some variables and rules, and I was left with only one rule which I changed to my liking and used as a template for the rest. If you’re not familiar with Makefiles, they’re fairly easy to understand when you figured out the syntax, which is admittedly a bit weird.
For now I list the files I use individually, so I need to add each new blog and wiki entry I create.to the list manually. Depending on where I use the files I pre- and append them with the directory and file ending respectively.

Blogc has 2 modes for compiling:

  • The standard entry mode
  • Listing mode

In entry mode, your entry and variables defined in the source file are available as usual. In listing mode blogc handles every source file taken as an argument. In your template, listing blocks are being executed for every source file to be compiled into one output file.
I compiled my homepage, about, the privacy policy, etc. in entry mode and, for now, will be compiling my blog posts in list mode. The reasoning behind this is that I’m trying to figure out how to generate a listing without listing the content, but will be looking into this another time.

That’s about everything I can talk about. The content as well as the design on this site is largely the same as before, with just a few changes that are probably not even noticeable.

Do you have a comment on one of my posts? Feel free to send me an E-Mail: witcher@wiredspace.de
To participate in a public discussion, use my public inbox: ~witcher/public-inbox@lists.sr.ht (Archive)
Please review the mail etiquette.

Posted on: December 21, 2020

Articles from blogs I read

I managed to stop biting my nails

watch out!Some sections of this article make nail biting sound appealing. If you're currently avoiding biting your own nails, please be careful reading in case they make you want to bite. Remove sentences from the article?For a long time, I haven'…

via Cadence's Weblog December 12, 2024

I'm daily driving Jujutsu, and maybe you should too

I’m not the first to write about how Jujutsu won me over. I’ve seen it off and on, and each time it came across my feed it was bumped a bit higher in my “list of things to look at eventually”. It finally reached the top spot, I think, when I saw Tony Finn’s …

via Drew DeVault's blog December 10, 2024

Launching the 2024 State of Rust Survey

It’s time for the 2024 State of Rust Survey! Since 2016, the Rust Project has collected valuable information and feedback from the Rust programming language community through our annual State of Rust Survey. This tool allows us to more deeply understand ho…

via Rust Blog December 5, 2024

Generated by openring