Static Site Generation with blogc
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.
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.
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
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.
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.