Setting up this blog

This blog is written in org-mode in Emacs, built by Hugo (Academic theme) and deployed via ox-hugo (see below for configuration) on github pages.

ox-hugo configuration

;; -------- Hugo --------
(require 'ox-hugo)
(setq org-hugo-default-section-directory "post")
;; Populates only the EXPORT_FILE_NAME property in the inserted headline.
 (with-eval-after-load 'org-capture
   (defun org-hugo-new-subtree-post-capture-template ()
     "Returns `org-capture' template string for new Hugo post.
 See `org-capture-templates' for more information."
     (let* ((title (read-from-minibuffer "Post Title: ")) ;Prompt to enter the post title
            (fname (org-hugo-slug title)))
       (mapconcat #'identity
                    ,(concat "* TODO " title)
                    ,(concat ":EXPORT_FILE_NAME: " fname)
                    "%?\n")          ;Place the cursor here finally

   (add-to-list 'org-capture-templates
                '("h"                ;`org-capture' binding + h
                  "Hugo post"
                  ;; It is assumed that below file is present in `org-directory'
                  ;; and that it has a "Blog Ideas" heading. It can even be a
                  ;; symlink pointing to the actual location of!
                  (file+olp "" "Blog Ideas")
                  (function org-hugo-new-subtree-post-capture-template))))

I also wrote a short function to redeploy the blog from within emacs.

(defun if/deploy-blog ()
  (let ((default-directory "/path/to/your/blog"))
    (async-start-process "bash" (executable-find "bash") nil "")

This makes use of a simple bash script to auto commit and redeploy to github.


echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"

# Build the project.
hugo -t academic # if using a theme, replace with `hugo -t <YOURTHEME>`

# Go To Public folder
cd public
# Add changes to git.
git add .

# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
  then msg="$1"
git commit -m "$msg"

# Push source and build repos.
git push origin master

# Come Back up to the Project Root
cd ..
comments powered by Disqus