Blogging from Emacs: Hugo & Org-Mode
Published September 4, 2017

I have to admit, I hate first posts. They are awkward, cliché, and most of them just serve as a weak preamble for the posts to come. I was just about to name this post Hello, World!. Since we are going to follow the cliché, let's follow the useful one at least: let's talk about technical details of the blog as such.

When I decided to create this blog, it was not only about the ability of writing my thoughts, experiments and projects in a website; not only about my personal brand. This time I also wanted to check if it was possible to maintain a blog just from Emacs. You know, I am a huge Emacs fan, I find that it is the editor that was easier to bend to my own will. I have been using it for around one year and a half now, and when one starts liking Emacs, there is a seductive idea: bring as many things into your Emacs workflow. Usually, the first step is to start using your shell inside Emacs' GUI; next step for me was taking notes in Org-Mode. Org is, for me, one of the most mind-blowing packages: a markup language designed to be able to hold different packages to perform all kind of tasks, from note-taking to literate programming or event scheduling and TODOs.

That's why I was specially excited when I saw that Hugo was adding support to write in Org. That meant that I could use completely migrate all the workflow of having a blog inside Emacs with almost no friction. All my org-tools can be applied now to the Hugo posts. Although, I was quite disappointed to see that the automatic post generation (hugo new post) was not generating org tags, that was already solved by Mario Martelli with a couple of functions.

In my opinion, using Magit there is not even the need to automatize the git procedure to deploy the blog, specially using GitLab Pages. Contrary to my experience with GitHub pages, where the page repository was a submodule (where Hugo would throw all the public elements generated from the markdown), in GitLab the page is deployed through artifacts in GitLab's Continuous Integration system. For that reason, we can just push the *.org files and wait for GitLab runners to post the content to the hosting. This is controlled with the /.gitlab-ci.yml file, that contains this simple script:



  - hugo
  - master

  - hugo
    - public
  - master

The variables set (not included in GitLab's tutorial) are included to correctly manage the Hugo themes as git submodules, that are recursively cloned when deploying. SSL is switched off due to a bug in GitLab containers. Once this build is completed, the site is generated and uploaded to the hosting.

Also, I think it is a great time to remind you all that it is possible to obtain free TSL/SSL certificates for your websites via Let's Encrypt. Using those certificates, I have been able to make the HTTPS version of this blog available. Now you can read all my ramblings and notes in a secure channel!