Welcome to my blog!

Hello, and welcome to my new blog!

I’ve owned the domain name winslowjosiah.com for just over a year, and up until this point, I’ve only used it for hosting a few small projects. But now that I have a blog, I’ll be using it to talk about whatever tech stuff I’ve been getting into lately. (I code a lot, but you wouldn’t know it from my GitHub activity. 😅)

First, I think I should blog about how I made this blog. Buckle up for some technical details…

Static site generator

There are countless blog websites that are made using some kind of “static site generator”. A static site generator will take content written in some format (like Markdown or reStructuredText), and use it to create a complete website – all the HTML, CSS, JavaScript, everything.

Many static site generators are available, and when I asked for suggestions on Mastodon, a few helpful folks threw out these examples:

In the end, I decided to go with Pelican, because I’m pretty comfortable with Python (and also, because I run another website called The Pelicanizer, the name was very on the nose).

Content format

My static pages and blog posts are written in Markdown, which makes them simple to write. The only thing for me to remember is to put any metadata I need at the beginning of the file, like so:

Title: Example Blog Post
Author: Josiah Winslow
Date: 2024-04-26 21:32
Slug: example-blog-post
Category: Misc
Tags: example, blog, post

This is the _content_ of my **blog post**!

Note

Only the Title field is technically necessary – and even then, I could avoid that with some config option – but I like having the metadata there. Even in some other Markdown viewer, you’d know exactly what this file is for.

For styling the website, there is a community-managed collection of Pelican Themes to choose from. However, I chose to use a custom theme instead; theme templates are written in Jinja, which was straightforward enough for me to learn the basics of.

One interesting application for Jinja templates is using them to write content directly in HTML/Jinja. Pelican is able to use HTML files as content, but the way they’re parsed doesn’t allow for a lot of flexibility. However, if I specify a Template field in the metadata of a Markdown file, I can effectively change the content of that page by changing that template file. In fact, here is the entire Markdown source for my “Projects” page:

Title: Projects
Slug: projects
Template: pages/projects

(All of that page’s content was written in a theme template!)

Directory structure

After spending a long time trying to customize my site to my liking, this is the directory structure of my Pelican project. It’s not exactly ideal, but hey, it’s mine.

Directory What’s in here?
/content/articles Blog articles, in Markdown
/content/images Images to include on the website
/content/pages Static pages, in Markdown
/content/scripts JavaScript files to include on the website
/plugins Pelican plugins, in Python
/themes/winslowjosiah/static Static files necessary for the theme (like CSS)
/themes/winslowjosiah/templates Page templates, in Jinja
/themes/winslowjosiah/templates/pages Page templates used for some static pages (with content written in Jinja)

Pelican plugins

Pelican supports plugins that can alter or extend its functionality without modifying its core directly.

At the moment, my Pelican project only uses two plugins: Neighbors (which adds a Previous/Next link to blog articles), and a custom plugin that extends the Markdown parser.

Tip

Originally, I had actually written a plugin to replace the default Markdown parser (Python-Markdown) with a faster one called mistletoe, but it turned out to have fewer features by default, and be harder to work with in general.

However, you could write a plugin in the same vein that reads content written in a different format. One person made a Pelican plugin that reads content in a custom format they call “Mau”.

My custom plugin adds four extensions to the Markdown parser:

Future work

One thing I’d love to add to this blog is a way for users to add comments. Pelican does support adding a comment section with Disqus, but I’m hesitant to actually set it up. Cusdis seems like a better option, but I will have to spend time figuring out how it works. And one interesting solution I’ve seen is to pull replies to a Mastodon post and display those as comments.

What do you think I should do here? I’d ask you to write a comment about it…but as of now, my blog doesn’t have a comment section. So I guess you can tell me about it on my Mastodon or Twitter accounts? I dunno.