/ mason kirchner / blog

making this blog

July 3, 2019

It was probably long overdue for me to set up a blog. Content on this blog will be some combination of Golang code, machine learning infrastructure, and doing fun stuff with football data.

To make this site I wanted to use something easy, and cheap so I settled on using Hugo, GitHub Pages, Notion as my content delivery tool, and CircleCI for continuous delivery. The only expense here is Notion coming in at $4 a month, but I already used Notion for daily note taking so I consider tying Notion to this site as me getting more bang for my buck.

The Notion part is definitely the most interesting part of this build in my opinion. It was inspired by this post, and I really liked the idea of simply being able to type into Notion and know that I could have the content published.

How I Built This

The workflow that I sought to create is one where I am able to write a page in Notion, and then have a job that I can trigger to pull that page and update my blog with the new page. In this section I’ll go into details for how I put this together for those that are interested in making something similar.

To manage the code base and deploy the website, I made two GitHub repositories:

Next I had to install Hugo, which can be done by following Hugo’s installation guide. After installing Hugo, I picked out hugo-theme-basic from the Hugo Themes website.

From here, I had to figure out how to interact with the Notion API. After inspecting the network calls while using Notion in my browser, I figured out that there were three requests I needed to use to keep this blog up to date:

  1. POST /v3/loadPageChunk
    • This returns a list of IDs for the blog post Pages I created.
  2. POST /v3/enqueueTask
    • This will queue up a Task that will export a Page with a given ID as a markdown file. It returns a Task ID.
  3. POST /v3/getTasks
    • Given a Task ID, this returns a markdown file representing the Page.

From here I was able to write a Python script to make these requests to fetch the markdown files that represent the blog posts. From there, I use a bash script to place those markdown files in the content directory of the repository, and then have Hugo generate the static site with those files. Finally, the updated code is used to make a Pull Request to the masonkirchner.github.io repository where I can review any changes to the website before I deploy it to production.

I’ll provide more specific code for this whole process in the next blog post for those that may have had a difficult time following along.

I’m really excited to have this blog up and running! Until next time.

-Mason

/img/35548070_10157564389803761_6880893514951950336_o.jpg