As someone who does a lot of work on the iPad, I have always wanted to be able to create efficient workflows for posting things to my various sites. This being a site that I own, it’s no exception.
One downside to moving the site from Wordpress to Hugo is that posting is basically a matter of putting the article content into a specific part of a markdown template, putting category and tag information into their designated part of the template, moving the edited file to the desired location for the post to appear, and recompiling the site with the “hugo” command.
I already knew I was going to make a shortcut to handle posting to the site for me, for the sake of ease and consistency. The beauty of automation is you never fat-finger a template edit and wind up having to fix something later when you notice. Also, with a shortcut for posting to my site, I can share directly from iA Writer and never have to leave my writing app for all this to happen.
It still leaves me with one problem though – in order to post things to my site without spawning a whole bunch of similar but different categories and tags, I want a list of existing categories and tags to choose from when posting, with the ability to also add new ones if I want.
In short, I want taxonomy menus.
I finally decided that the simplest way for me to handle getting the list of currently used taxonomy terms into shortcuts to construct menus with was to create a taxonomy list page that gets automatically updated with current used taxonomy terms every time the site is compiled. That is, I don’t have to maintain the list – Hugo does it for me.
With this taxonomy list page just sitting there waiting for me to notice and admire it anytime I feel like it, I can put the power of regular expressions to use and create lists of site sections, categories, and tags, and then create menus with them for me to select terms from.
My solution was to create a separate shortcut that handles just the taxonomy menu building and passes a quoted, comma separated value list of my selected terms back to the main blog post publishing shortcut for putting into the appropriate place in the blog post markdown file.
The reason I create quoted CSV lists instead of just plain old CSV lists is because inside the hugo markdown file, taxonomy terms are expected to be put into string arrays, and items in string arrays have quotes.
Rather than running my taxonomy menu shortcut once and returning three lists of terms to the shortcut all at the same time, I call it three times, once for sections, once for categories, and once for tags. It could certainly be modified to send back a dictionary of the three lists at once though, which would eliminate the need for me to call it three times and tell it which taxonomy menu I want each time.
I made a video about some of the shortcuts specifics in case you’re interested. A moving picture says 100,000 words, and who doesn’t love videos of shortcuts hopping all over the place as they execute?
One more note about this is that I use Toolbox Pro to construct the menus with because it can create fancy menu items with the look I want, and one inescapable fact about stock UI items in Shortcuts is that they aren’t very visually appealing.