Follow the instructions found on this site to “Create a clickable script”. Then use this code…
Notes:
The code will prompt you to enter a name for your new post, avoid spaces and underscores in the name, use a dash instead, for example: my-new-post .
You will be asked to input your system login password, this is to grant the script permission to move and create folders.
You will need to edit the code to show your hugo folder name, and your system login username.
After creating your new post you will then need to enter the title in the front matter of the index.md file.
cd /
cd your-hugo-folder/content/posts
name="$(osascript -e ‘Tell application “System Events” to display dialog “Enter the post name:” default answer “"’ -e ‘text returned of result’ 2>/dev/null)” if [ $? -ne 0 ]; then # The user pressed Cancel exit 1 # exit with an error status elif [ -z “$name” ]; then # The user left the project name blank osascript -e ‘Tell application “System Events” to display alert “You must enter a project name; cancelling…” as warning’ exit 1 # exit with an error status fi
sudo mkdir -p $name
touch index.md
sudo cp /your-hugo-folder/themes/hugo-kiera/archetypes/posts-create.md index.md
sudo cp index.md $name
rm index.md
sudo chown -R username:staff /your-hugo-folder/content/posts