After getting fed up with trying to manage several different PHP versions on the same server, trying to manage several servers running different operating systems, web servers, databases, etc. for all kinds of different purposes (usually websites, but you’d be surprised), I’ve decided to embrace the cloud and host my website on someone else’s machine for once.

In this case, I’ve chosen Netlify and moved over my professional portfolio site, my photography gallery, and now this blog.

Portfolio site

I’ll start with the portfolio site. Before, it was a pretty simple collection of PHP pages. The content is mostly static, but I used PHP to include the same header and footer content, as well as show the file’s last modification date in the footer. Instead of redesigning my whole site as a theme for a static site generator, I wrote a simple build script:

$src = array_diff(scandir("src"), [".", ".."]);

foreach ($src as $template) {
	$output_file_name = pathinfo($template, PATHINFO_FILENAME) . ".html";
	echo $template . " -> " . $output_file_name . PHP_EOL;

	ob_start();
	{
		include "src" . DIRECTORY_SEPARATOR . $template;
	}
	file_put_contents("site" . DIRECTORY_SEPARATOR . $output_file_name, ob_get_clean());
}

This takes every PHP file in my src/ folder, evaluates the PHP template by running the script file, and saves the output to an HTML file to site/, which Netlify then serves. Since I wasn’t serving visitor-specific content, this makes for a faster and much simpler site with minimal effort and no change in appearance or URL structure (since I had file extensions hidden before anyway).

I set up Netlify to run php build.php when I push to the GitLab repository containing these files and it was good to go.

The photography gallery was a little more involved. I had been using Zenphoto, which is a pretty bad but still loveable photo CMS. It had a ton of features that I never needed, and was therefore a lot slower than necessary. I replaced it with thumbsup, which is a static site generator that takes my folder full of photos and turns subfolders into album pages.

The weirdest (and coolest) part of thumbsup is that it reads the image metadata. This might not seem like a huge deal (even Zenphoto displayed the EXIF data under the images), but the concept of determining site structure based on this data is new to me. One of my albums is a collection of the photos I personally think turned out the best. To create this album, I added a rule to thumbsup that matches photos whose metadata rates it as 5 stars, then I used a photo editor to add such metadata to several photos from different albums.

I do wish it would create individual pages for individual images, but I don’t see a way for even a custom theme to accomplish this. I would settle for unique URLs so that I can link to individual photos within an album, and I might investigate a JavaScript approach to this.

I would also like to display that featured album as a slideshow on the homepage instead of leaving it buried with my other albums, but I couldn’t find an easy way for a theme to pull images from a specific album due to Handlebars limitations on logic complexity. This led to a weird project that I will cover in a later post.

Blog

Last (and a little bit least), is this blog itself. It’s been a long time since I’ve had a blog, and even longer since I’ve made more than a couple posts on one, but I’ve been doing a lot lately so I felt like I needed the space to write out my thoughts and processes. Even moreso during these times of stress and uncertainty.

I wanted something easy, so I decided to give Hugo a try instead of writing my own static generator like I did for the portfolio site. As you can see, I decided to go with the Terminal theme, but I changed it to use a non-monospaced font to make it easier to read for anyone not used to reading code. I’m sorry/you’re welcome.

Hopefully I’ll keep it updated, and maybe eventually I’ll post something useful. We’ll see.