The last iteration of this blog was a Go program running on Digital Ocean's cheapest VM ($5/month).
Recently I've made 2 big changes:
- I converted it to a static site hosted on Netlify
- I used Notion for writing the posts instead of writing markdown files in a text editor
Moving to Netlify
My blog was effectively a static website. It didn't need a backend so writing a custom server and running it on a VPS was overkill.
Few months back Netlify reduced the price of their cheapest plan to $0 (from $10/month).
I'm always looking to simplify and cheapify my life so I bit the bullet and converted my custom server to generate static HTML files suitable for hosting on Netlify.
If you want to publish a static website and are starting from scratch, the best approach is to use one of the many static site generators (e.g. Hugo or Jekyll).
I already had a lot of content in .html and markdown files accumulated over the years and code to generate the website for serving from custom web server so I refactored to code to generate static HTML instead.
Refactoring process was time consuming but simple.
For dynamically generated html I changed the code to generate a .html file and setup appropriate url => file mapping using
For local testing I use Caddy and generate
Caddyfilewith appropriate redirects. There are minor differences when testing locally because there are semantic differences between redirect capabilities of Netlify and Caddy but it's good enough.
Netlify also has an option to do a draft deploy under a unique URL. This is good for previewing the changes before publishing.
At the end of code refactoring I effectively ended up with a custom static site generator.
I'm happy with the result.
Netlify has all the features I care about for a basic website.
Notably they provide free SSL with Let's Encrypt, allow custom domains and have capable redirect capabilities. They use CDN so should be faster than hosting on a single host.
The only thing I miss is being able to see analytics for 404. With my own server I was logging all requests for pages that don't exist on my server. Many of them were bots trying to hack me via known vulnerabilities in popular software like WordPress but sometimes it would be caused by my mistake or a request for a valid article incorrectly linked. Seeing those I was able to fix most of them by adding redirects.
I hope Netlify can sustain their generous free plan.
Luckily there are plenty of options to host a static website so even if Netlify goes under, it'll be easy to move somewhere else, like Firebase Hosting, surge.sh, GitHub pages, GitLab pages and many others.
Using Notion as Content Management System
The easier it is to write, the more I write.
I failed the "as easy as possible" part.
In absolute terms, creating a new markdown file and writing a post doesn't take much time.
In practice it's enough friction to deter me from writing. In my worst year I only wrote 1 new blog post.
fIn a perfect world I would open an app and start writing. When I'm done writing I would publish with a click of a button.
Notion is as close to a perfect writing tool as it gets: open a page and start writing.
The problem is: all that content is trapped in Notion. You can publish (publicly share) a page but I want more flexibility:
- I want to host on my own domain; my website is partly a tool for marketing myself
- I want integration with Google Analytics
- I want a custom design
- I want to provide rss feed
Thankfully I'm a programmer: if something can be done with software, I can do it.
I started a one-man Notion Liberation Front. My goal: liberate content trapped inside Notion.
I reverse-engineered their API, wrote a Go library and after another round of code refactoring I had my blog powered by Notion thanks to this Go program.
I imported my old blog posts into Notion. They have a decent markdown importer although I did have to do some cleaning up.
I went even further and published most of my notes to my website as well. I still have many private notes in Notion but most of them can be just as well be publicly visible.
There's no way I could do publish so much content without Notion.
I also automated publishing by using cron functionality in Travis CI. Every day a script downloads latest content from Notion, caches it in git repository and re-generates a website.
Everything now runs on auto-pilot. I can just write new articles in Notion and my website will be automatically updated every day.
Go to index of articles.