Dev life

Writing blog with ox-hugo

September 26, 2018

In the past six months, I keep using Spacemacs to write code and it is very handful. So I wonder how to write articles in Emacs. After searching around, Hugo came into my eyes. Just following the tutorial, install the binary, clone a theme, and run the server, a blog is built in less than 5 minutes.

brew install hugo
hugo new site blog
cd blog
git clone themes/hyde
hugo server -t hyde

After that, I installed ox-hugo and begin to write a post in blog/content-org/ Yes, all articles are saved in one org-mode file, you can find the benefits here.

The content in the org file is as following:

#+HUGO_SECTION: ./blog/

* First article
  :EXPORT_FILE_NAME: first-article
  :EXPORT_DESCRIPTION: First article with ox-hugo

  Hello, this is my first article

After writing the article, use C-c C-e H H to generate the post or C-c C-e H A to generate all posts.

Then you have multiple choices to host the blog, I choose Netlify as it can auto deploy after pushing to Github. It is very easy to use, supporting custom domain and SSL certificate for free.

Happy writing :)


Written by goofansu who lives and works in Shanghai, China building useful things. Follow him on Twitter