How to Write and Export Hugo Blog Posts with Bear and Bhugo

Tue Apr 23, 2019
go golang hugo bear

I use Bear as both a note taking application and a platform to write my blog posts. Bear is fantastic, but I found exporting posts out of Bear and into a Hugo file for my blog is a bit tedious — the images don’t copy over properly and I still have to write the front matter for the posts within Hugo. Wouldn’t it be amazing if I could just write my blog posts exactly as I normally would within Bear and have them just appear in my Hugo site and be able to see them on my local Hugo server instantly?

I wrote a simple utility in Go to do just that called Bhugo. It monitors a particular tag in Bear (Bear notes are organized by tags or nested tags, for example #blog or #blog/golang), performs some transformations, and writes out a file to the directory of your Hugo site. This lets you run the live-reloading local Hugo server and immediately see changes in your Bear note reflected on your local Hugo server. Sweet!


Getting up and running is simple. You’ll need to have Go installed and then you can run go get to install Bhugo.

Create a .bhugo file wherever you like - a good spot is in the root of your Hugo site. You’ll need to configure this file with several values:

DATABASE="/Users/<username>/Library/Group Containers/ Data/database.sqlite"`  

Substitute your username in both values and your blog directory path in HUGO_DIR. Check out the readme for detailed instructions on other configuration options.

Pull requests, feature ideas, suggestions, bug reports, and whatever other feedback you have on the project are more than welcome!

back · blog · about · main