Automatic posts with Siri Shortcuts
Motivations
I’ve been using Siri Shortcuts to keep my site up to date with my music listening habits, which has been working great. I haven’t seen guides detailing how to add content to Hugo with Siri Shortcuts, so I made one.
I recently switched to Apple Music from Spotify1. One of the best parts of switching is being able to use Siri Shortcuts to manipulate your music library. With Siri Shortcuts you can quickly create new playlists or see what music you have listened to lately. Or you can share your music with the whole world every week.
Why I’m a Fan of Hugo+Shortcuts:
- Shortcuts has a great action for working with health data (used to upload my weekly running times) and music (used to upload my listening history).
- Shortcuts can be automated on iOS to run at a certain time each week without your input.
- Uses a static site which is fast for users and cheap to run.
- Markdown is super easy to manipulate with Shortcuts, making it easy to create posts with nice formatting and images.
It’s easy to move around variables and get your post just right with Markdown and Siri Shortcuts!
This relies on a remote server building Hugo from your GitHub repository. I use Cloudflare Pages, but the process should be near identical for other hosting platforms.
Guide
-
Create a website with Hugo. Create new content and draft your updatable webpage.
-
Download the Working Copy app, sign in, and clone your repository.
-
Download my Siri Shortcut: Add This Weeks Music To Hugo.shortcut . Here’s how the shortcut works:
- Creates a counter variable to number the ten songs
- Gets the current date and formats it nicely for Hugo
- Gathers 10 random songs played in the last week that have album art
- Makes sure there is at least one song in the output
- Grabs the album art for the songs, resizes them, and makes a banner with the Combine action
- Saves the combined image as
Image.jpg
- Uses the repeat action to capture the song title and artist name and increments the counter by one; adds formatting to song titles and artist names
- Combines all of the text fragments into one text variable
- Creates a new text variable with the proper front matter and blog content
- Sets the name of the post to
index.md
- *Important* saves the
Renamed Item
variable - Pulls your GitHub repo, then stages, commits, and pushes the changed directory with an auto update message and date variable
To get it set up, change the directory for each of the file save actions to the location you created in Step 1. Change the repository in the Working Copy actions to your repository.
-
Run the Shortcut.
-
Check Cloudflare Pages status. If it has built successfully, check your webpage to see the updated version. Example of commit message and successful build on Cloudflare Pages
-
If everything is working, automate your Shortcut to run automatically. Start the Shortcuts app and go to
Automation > + > Time of Day
. Set your frequency and time (keep in mind Cloudflare limits Pages to 500 builds per month, as of 01-03-23). Select your shortcut. Open your newly created automation and selectAutomation > Run Immediately
to make sure the automation runs on time.
The full library of Shortcuts actions is available to customize the look and behavior of your page. Thanks for reading this guide! Feel free to email me with questions.
Example
See an example of these auto updated pages on my website at rudytoepfer.com/music and rudytoepfer.com/fitness.
-
Switching because I’m done with: Podcasts that can’t be hidden. Spotify algorithms suggesting the same 20 songs anytime I make an algorithmic playlist. Concert and new release ads from artists I don’t care about (these can’t be disabled). Getting rid of liking songs (♥) and replacing it with a (✓) that just means a song is in one of your playlists. A normal queue situation that lets you add a song up next and skip around without it disappearing. Missing Neil Young’s music. ↩︎