New Year, New Build Script

For the past few months, I’ve been incredibly busy with college. I was supposed to post on December but I ended up working on a new build script for the website instead. I was already using rgz.ee’s ssg script modified to use pandoc instead of lowdown for converting markdown to HTML. The change was mostly pointless because lowdown could do whatever pandoc does.

The one thing I do like about pandoc is the metadata feature. I don’t think lowdown can really do that so I decided to make my own build script that makes use of the feature. I started working on one using whatever knowledge I have on bash scripting (which is very limited). I had to learn how to use sed, grep, printf and other commands.

I wasn’t able to finish it before my break ended. It was enough to do exactly what rgz’ee ssg script did but I wanted to really utilize pandoc’s metadata.

January came and it was hell. It was finals so I was working on papers pretty much everyday. During my birthday, I had to stay up for nearly 24 hours just to finish one of my papers. It turned out pretty well though. My professor was pleased. I intend to rewrite it as a blog post here sometime in the future, together with some of my older essays and papers.

I finally finished everything by the 19th and since then all I’ve been doing was playing League of Legends. You heard me. For the past two weeks, I’ve been playing League of Legends. I don’t want to explain why. This game sucks.

The new build script

I completely neglected the website but for the past few days I continued working on the build script. I had forgotten how to use sed and grep already so it took a while. What I ended up with is a complete mess but it does work. It now reads keywords which one can use to filter out the index, it builds the RSS feed and the site map as well.

I originally wanted to make it automate the videos section as well, but I’m still figuring out how to do that. For those interested, I’ll make the build script available here.

Just like rgz.ee’s script, all you have to do is supply some markdown files and it will automatically convert it over to HTML files. You need to follow a certain directory structure. The base directory should be domain.tld/ and the blog directory should be domain.tld/blog. It ignores any directory that starts with an _, so you could use _drafts to store your post drafts for example.

You also need to supply your own domain.tld/template.html file. If you’re familiar with pandoc, then you should know what this does. Basically, it’s the template all your markdown files will use as a template. It’s essentially the header and footer file but as one file for those who have used rgz.ee’s ssg before. Here’s an example of mine:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="$description$$abstract$">
<meta name="author" content="$author-meta$">
<meta name="date" content="$date-meta$">
<meta name="keywords" content="$keywords$">
<link rel="icon" type="image/x-icon" href="/media/img/favicon.ico">
<link rel="stylesheet" href="/style.css">
<title>$title$ &mdash; maky.me</title>
<body>
<header>
<nav class="top">
    <table>
    <tr>
    <td class="logo">
        <a href="/">マキー</a>
    </td>
    <td class="links">
        <a href="/">Home</a> ·
        <a href="/blog">Blog</a> ·
        <a href="/videos">Videos</a>
    </td>
    </tr>
    </table>
</nav>
<hr class="line">
</header>
<main>
<h1>$title$</h1>
<p><em><time datetime="$date-meta$">$date$</time></em></p>
$body$
</main>
<footer>
<small>Disappointingly made by Maky. <a href="/license.txt">License</a>.</small>
</footer>
</body>
</html>

When writing your pandoc metadata on the markdown file, it will be referenced to the HTML file. For example, I use the $title$ to create an h1 title element for the blog post and I include a date below using $date-meta$.

Obviously, the $body$ variable is the most important one here. <main> is also very important as the script uses this as reference to where the main content of your post is so always include that.

The script takes care of removing unnecessary metadata for non-posts. For example, the index.md doesn’t need $author$ or $date$ so it deletes those lines.

It also generates tags for the blog index and maybe in the future, I’ll include generating tags in the blog post itself. It should be easy enough with the pandoc template and some sed and grep.

The script spits out the entire website in the _public directory. You can copy that over to your server with scp.

That’s pretty much all there is to know about the script.

I plan to add more features in the future and I’ll keep the build script as up-to-date as possible.

Commitments to the website

I intend to continue writing posts on this blog. So far there really isn’t anything in here yet but I expect to publish maybe two to four posts per month. I plan to rewrite some of my past papers or write some new ideas. I know almost all the posts here right now are about software but I’ll be sure to begin moving the focus of the blog to what it really is intended for: essays on media.