The Idea Of Makefile Blog
last updated 2020-06-26 20:37:30 by met
Nowadays, even the simplest static website generator are overly complicated and requires too much effort to learn and customize.
A possible solution to this problem was use of easily accessible tools -if not already shipped with distro- with the power of
As seen on the folder tree, name of the post files are also title for the blog posts but underscores which then gets replaced used instead of spaces. The way
P.S: The project can be found at Github, this blog itself is made with makefile blog.
GNU Make
. First think I did was searching similar implementations with a makefile but I had no luck except for some generators
which basicly call a script already written in a high level language and it lacked the extensibility theme wise.
Structure
The basic structure involving in the Makefile Blog is templating throughenvsubst
included in gettext
package.
Various information including author, creation time and update time is read by stat
from filesystem metadata which might not work
on some filesystems or configurations but tested on ext4 and ntfs. The posts are written in html and should be saved under posts directory
with no extension. The rationale behind the choice of html over markdown is because html is native language of the web and use of anything else is
just waste of computation in my opinion since it requires additional dependency to a md to html converter such as pandoc
.
Static files are stationed under posts/static
folder and recursively copied to build/static folder among with any css file under current
template folder. So inner structure of static files are not defined but preffered use can be seen in the folder tree.
As seen on the folder tree, name of the post files are also title for the blog posts but underscores which then gets replaced used instead of spaces. The way
Make
interprets spaces is interesting and usually breaks stuff.
Configuration
Configuring the makefile blog is easy. Variables in the makefile can be either manually modified or given through environment. Some fields you may want to change as following: The blogroot can be blank if the blog is on the root of the domain. If you have placed your blog under a directory namedblog
, you may set
BLOGROOT
variable to /blog
. If you need absolute urls for some reason, you may set BLOGROOT
variable to your domain such as
https://www.example.com
. Further configuration available in the makefile
Templating
Any template under templates directory can be choosen by editing the makefile or by giving the related environment variable asmake TEMPLATE=tmpname
.
The default template is an example to show minimum set of files required for a template. Every template must have these files to satisfy requirements for all
targets available in the makefile. The template files use environment variables set by makefile during the building process similar to ${TEMPLATE_POST_DATE_UPDATED}
or ${TEMPLATE_POST_AUTHOR}
to show content.
Result
The makefile blog is as simple as creating a text file mixed with html tags under./posts
and running make
.
I have tested the default template on various browsers including the links
.
The default template is mostly usable in links and no major problem is visible. Since this is a minimal template,
no external css file were used. The template is more or less compatible with mobile devices as far as my
non-extensive tests. Overall compatibility is okay across devices.
P.S: The project can be found at Github, this blog itself is made with makefile blog.