This website was previously compiled using Hugo. Hugo has a rather robust templating system, something I became fairly dependent on to create new blog posts, research pages, or class pages. It is a functionality that I sorely miss with the new version of this site that is built with Quarto. I have lived with this for a while, as I sorted out the finer details of this site—not everything transferred one-for-one. Now that things are more or less settled, I’m looking for more quality of life upgrades so that I can use this site a bit easier.
Enter Raycast. I use Raycast for lots of things on my Mac; launching apps, searching the web (and specific parts of the web like Google Scholar), running little scripts (see Key light shenanigans), etc. So, naturally, it seemed like a good way to automate creating the framework for a new blog post on this site.
Some logistics. This blog lives in the /blog/ folder and each post is also a folder named /YYYY-MM-DD-title-as-slug/. So, I need to replicate that. Raycast can take arguments and pass them to a bash script. Below is the general format for that (more information here).

So, I open Raycast, type Create Script Command, enter a few bits of info, and save it. This creates the framework for a shell command. And you can see the output of that work, some taken from Andrew Heiss, and some from me. The command asks you for the title of the blog post you want. It then grabs today’s date, formats that text into a 5 word slug, and creates the folder necessary to get the process going. It then creates a index.qmd file with the necessary template information to begin a blog post.
Now, I enter the title of the post I want to make into Raycast, and I get out the shell of a post that I immediately begin editing. This should be relatively easy to remux into a templating system that allows me to recreate almost all of the Hugo functionality I enjoyed before.
If you want to try it for yourself (and not necessarily just with Raycast, this is a bash script, so it could be used in several ways), see the Gist below.
| #!/bin/bash | |
| # Required parameters: | |
| # @raycast.schemaVersion 1 | |
| # @raycast.title New Blog Post | |
| # @raycast.mode silent | |
| # Optional parameters: | |
| # @raycast.argument1 { "name": "title", "placeholder": "Title", "type": "text", "required": true } | |
| # @raycast.icon ✉️ | |
| # Documentation: | |
| # @raycast.description Create New Quarto Blog post | |
| # @raycast.author Chris Goodman | |
| # @raycast.authorURL https://hello.cgoodman.com | |
| # Check if folder name is provided | |
| if [ -z "$1" ]; then | |
| echo "Error: No post title provided" | |
| exit 1 | |
| fi | |
| # Get the current date in ISO-8601 format | |
| yaml_date=$(date +%Y-%m-%d) | |
| # Format title | |
| lower_string=$(echo "$1" | awk '{print tolower($0)}') | |
| slug=$(echo "$lower_string" | awk '{for (i=1; i<5; ++i) str=sprintf("%s-%s",str,$i)}END{print str}') | |
| # Build the full path; format to your filesystem | |
| full_path="$HOME/website/blog/$yaml_date$slug" | |
| # Create the directory | |
| mkdir -p "$full_path" | |
| # Create index.qmd with template | |
| cat > "$full_path/index.qmd" << EOF | |
| --- | |
| title: "$1" | |
| date: "$yaml_date" | |
| description: "DESCRIPTION HERE (150-160 characters)" | |
| image: "img/BLAH.png" | |
| twitter-card: | |
| image: "img/BLAH.png" | |
| open-graph: | |
| image: "img/BLAH.png" | |
| categories: | |
| - SOMETHING | |
| format: | |
| html: | |
| fig-cap-location: margin | |
| code-copy: true | |
| --- | |
| CONTENT HERE | |
| EOF |