More Hugo automation

    I publish my blog via and Netlify. I've been using Magit to do the heavy lifting of getting my stuff off my PC and onto github. But it's a bit tidious. I really want one command to do it all.

    So, I started off with an elisp function:

      (setq hugo-base-dir (concat ps-2nd-home-dir "Code/Websites-source/petersmith/")
    	hugo-buffer "*hugo*")
      (defun hugo-publish ()
        (setq ps/commit-message (read-from-minibuffer "Commit message: "))
        (let* ((default-directory (concat (expand-file-name hugo-base-dir) "/")))
          (when (call-process "bash" nil hugo-buffer t  "-c" (concat "./ " ps/commit-message))
    	(message "Blog published"))))

    which calls my shell script

    DESCRIPTION="${@:-"A new post"}"
    echo "The commit message is:    " \"${DESCRIPTION}\"
    echo "The working directory is :" `pwd`
    git add . &&  \
    git add -u && \
    git commit -m "${DESCRIPTION}" && \
    git push origin master

    That hardest part was escaping the DESCRIPTION variable.

    If you webmention this page, please let me know the URL of your page.

    BTW: Your webmention won't show up until I next "build" my site.

    Word count: 200 (about 1 minutes)


    Updated: 7 Jun '21 16:48

    Author: Peter Smith


    Section: blog

    Kind: page

    Bundle type: leaf

    Source: blog/2021/06/07/more-hugo-automation/