This blog uses the framework Hugo to help create the content you see here. I had a really intelligent & professional reason for choosing Hugo: I had never used it before, and it looked fun.

Most of these static website generators use markdown as their primary storage mechanism for content. But here’s the thing about writing in Markdown — it’s awful. It looks like code, it’s hard to envision what it will look like on the page, and for the love of all things I can never remember if a link is written as [My link](https://mylink.com) or (My Link)[https://mylink.com].

Writing in Notion on the other hand is a thing of beauty. I love its interface, how I can categorize my writing easily and quickly, and how I can turn a page into a distraction-free writing experience. Big fan.

So, being a developer, I naturally had to write an integration, and with a newly released Notion API , I was in luck! I wrote a package named n2h which pulls a page from Notion, converts it to Markdown, and inserts it into a specified place in your Hugo blog project.

One consideration for me was that I like to use Github Gists for my codeblocks in my Hugo blog. Lucky for me Hugo has a built-in shortcode that makes this easy to do, but I still need to integrate with Github as well. My package will take any codeblock in the given Notion article, create a Github Gist, and insert that into the Hugo article.

Setup #

Required Variables:

  • notionAPIKey — create a personal integration here (and don’t forget to invite your integration to your database with your writing like in this example !)
  • databaseName — the name of your Notion Database where your writing will live
  • githubPAT — follow instructions here to create a token; requires full gist access
  • contentPath — the full path to the directory that n2h should place its finished markdown file (eg myblog/content/posts)

Installation #

Make sure you are in the n2h directory, then run make install! That’s it. You should now have an executable n2h in your $GOPATH/bin (and hopefully your PATH as well).

Usage #

n2h accepts three flagged arguments:

—status-property

  • This is the name of the Notion Property that we should use to filter out pages in our Notion Database
  • Required: false
  • Default: Status

—status

  • The actual status of the page you’re looking for that should be published
  • Required: true

—title

  • The title of the page. This is case sensitive. The program will first try and find a page with an exact match, then if nothing is found, it will perform a “begins with search.” So, for example, if my page title was “How I Use Notion At Work”, I could use either --title="How I Use Notion At Work" or --title="How I Use" and both should work (assuming you have no other articles with the same title beginning)
  • Required: true

So let’s say I have a database named “Writing Projects,” and on this database I’ve configured a property called “Writing Progress” that had options of “Idea”, “In Progress”, and “Ready to Publish”. I just finished my article named “20 Things I Love About Skiing” in Notion and am ready to port it to Hugo. I would first move that article into the “Ready to Publish” status. Then, after configuring the secrets.yml and installing the program, I would simply run (from any directory)

And boom! 💥 You should see your new article in your Hugo blog.

Obviously there is tons of room for improvement here, since I built this mostly for my own personal use. If you do end up using this service though, drop me a line and let me know! Also feel free to submit any pull requests to the Github repo which can be found here .