diff --git a/src/blog/2025-02-27-static-site-generation.cfg.php b/src/blog/2025-02-27-static-site-generation.cfg.php new file mode 100644 index 0000000..b14dd03 --- /dev/null +++ b/src/blog/2025-02-27-static-site-generation.cfg.php @@ -0,0 +1,6 @@ + diff --git a/src/blog/2025-02-27-static-site-generation.html.php b/src/blog/2025-02-27-static-site-generation.html.php new file mode 100644 index 0000000..3e71be0 --- /dev/null +++ b/src/blog/2025-02-27-static-site-generation.html.php @@ -0,0 +1,57 @@ + + +
+Over the course of the decade (maybe more) that this website has been around +I've gone through a few different frameworks and infrastructure for it. Although +usually this would be going back-and-forth between PHP and some static site +generator. For a while I've used Saait,[1] which +was perfect for my goal of simplicity, but was not at all flexible enough for +what I wanted. It seems to be intended for a website that contains a single page +and then a bunch of blog posts (not my setup), and so for a while I had a +somewhat jury-rigged setup. +
+ ++Seeing this as an issue, I decided to try my hand at writing my own static site +generator. There were a few failed projects like this, but I normally ran into a +few errors normally because of the language I would try to write the program in. +There was a time where I would try in Rust just for the heck of it, but I would +get bogged down by the compiler whining at me. Later I would try again in Bash, +but that was silly because of all the limitations that Bash presents (even Saait +isn't written completely in Bash). I finally started working on one in C (in a +private repository at the moment), but at this point in my life I'm much too +busy to actually work much on it. +
+ +
+Ultimately, with all this going on, I decided it was time to try out static site
+generation with PHP. Confused? Just run the PHP program on one of your PHP
+scripts. It outputs the exact same thing. All I needed to do really was to write
+a script that would go through all the PHP code in my website and output it as
+an HTML file (or XML in the case of RSS and Atom feeds). The only caveat was
+going to be my blog, which could get messy because of how I would need to access
+certain metadata about my blog posts (e.g. title or date) in order to generate
+both the blog page (to generate the page automatically) or the RSS and Atom
+feeds. This I solved by simply having files suffixed with .cfg.php
+which would not be processed.
+
+All this added up to the phpsg.sh
script[2],
+which I had added to my repository. It's licensed under the Zlib license, if you
+want to use it for your own websites. Hopefully I may continue to develop my
+static site generator in C, but until that's done, this is a decent substitute.
+