It has been a bit too cumbersome to make posts because I always have to navigate around the Hugo directory and remember how to write out the front matter of Markdown files. Here’s what a typical structure looks like for a Hugo blog post:
---
title: "OSX app for blog post"
date: 2025-02-18T20:59:38
draft: false
tags: ["fluff"]
image: "images/2025_02_18.jpeg"
---
{Body}
So I made an app using AppleScript that creates a Markdown file in the blog content directory, fills out a front matter template, and opens the file in Sublime. Check it out:
Expand Script
set blogDir to "/Users/xxxx/blog/content/posts/"
set imageDir to "images/" -- Hugo expects images here
-- Generate date stamp
set dateStamp to do shell script "date +%Y_%m_%d"
-- Initialize counter
set counter to 1
set fileName to dateStamp & "-Untitled.md"
set filePath to blogDir & fileName
-- Check if the file exists, and increment the counter
repeat while (do shell script "test -e " & quoted form of filePath & "; echo $?") = "0"
set counter to counter + 1
set fileName to dateStamp & "-Untitled-" & counter & ".md"
set filePath to blogDir & fileName
end repeat
set imageFile to imageDir & dateStamp & ".jpeg" -- Assumes image matches the date
-- Create the Markdown file
do shell script "echo '---
title: \"\"
date: '$(date +%Y-%m-%dT%H:%M:%S)'
draft: false
tags: [\"fluff\"]
image: \"" & imageFile & "\"
---
' > " & quoted form of filePath
-- Open in Sublime Text
tell application "Sublime Text"
open filePath
end tell
Works Great!