As of a few minutes ago, I've swapped out the Python backend of Kirsle.net with a new Go backend that I've been rewriting from scratch the past few months.
The Go codebase is a little rough around the edges and I'll be refactoring it over time. This is the first blog post on the new platform, so let me tell you about my open source Go blog!
As well as the backend, I've also made some tweaks to my frontend to make my website more privacy-conscious:
I have removed all advertising from my site. My Google AdSense ads were only making me about $100 every 3 months or so, which wasn't really worth it.
I've also gotten rid of Google Analytics, because I never actually check those things. If I get curious in the future, I'll install a self-hosted analytics app.
The new Blog code doesn't store IP addresses in any of its database files. I don't want to know your IP.
I'm taking my own advice from my recent blog post about storing IP addresses.
I've always been a proponent of keeping web apps simple and accessible. I don't take it to the extreme of The Motherfucking Website, but I'm a believer that web apps should speak HTTP, send server-rendered HTML pages, have <form>
s that actually POST
, and not require the user to enable JavaScript to function.
An example of this is with the ACE Code Editor that I'm using in the Blog and Page Editor views: when the page loads by default, the CSS instructs it to render a plain old <textarea>
with the page's contents. And then a JavaScript initializes ACE and toggles things around to enhance the experience, but the page is perfectly serviceable without scripts. The form POST
s to the back-end and gets an HTML response, none of that Single Page App, ajaxy stuff.
I'll write a dedicated post on this idea sometime later.
I've designed my Go Blog to be ridiculously easy to use. All you need is the binary, and you run it while giving it the path to your site's document root. The document root doesn't need to exist; it will be created as needed.
If you have a Go dev environment set up:
export GOPATH="${HOME}/go"
export PATH="${PATH}:${GOPATH}/bin"
go get -u github.com/kirsle/blog/...
cd ~/go/src/github.com/kirsle/blog # enter the blog's source folder*
blog /path/to/document/root
# * The blog uses a dual template system where it checks your custom document
# root first and then its built-in files. But the command's working directory
# currently needs to be the Blog git root, where the "./root" folder is
# available. This will be fixed shortly.
That's it! The blog uses a JSON database, which it will store in your ${document_root}/.private
directory (HTTP requests for dotfiles are prohibited by the Go server), and the website configures itself. All you need to do is just point it to a folder and visit it in your web browser at localhost:8000 to set it up.
If you don't have a Go dev environment set up, wait a while and I'll post binary releases when the code is more polished.
See blog -help
for other command line options, such as binding to a different port number or enabling debug logging.
Compared to my Python blog, Rophako, my Go blog is either less ambitious or more focused:
/photos/*
URIs will now 404 - oh well! I may bring them back another day./wiki/
directory.blog
command and give it a Document Root directory to serve your custom web files from. This directory doesn't even have to exist!.layout.gohtml
to change the overall web design layout./blog-title-name
Page editor
.layout.gohtml
, as a Go templating error might lock you out of the front-end completely! For that I'd recommend editing the template outside of the frontend.Pages don't have comment forms by default, but you can add them with a Go template directive:
{{ RenderComments "Subject Line" "unique-thread-name" }}
It shares a lot in common with Rophako:
.gohtml
, otherwise the HTML page will be served as-is (without the .layout.gohtml
wrapper). This is because Go templates are very fragile and you wouldn't want HTML pages that don't know they're templates to be unable to render!Both Rophako and the new Go Blog support showing how long it took a page to render on the page itself.
Rophako consistently took about 0.103
seconds to load the home page with the five blog entries and such. Using the same data, the Go Blog was able to render the homepage in 0.0020
seconds. That Super Scientifically Measuredâ„¢ benchmark shows that Go runs circles around Python, but I already knew that.
So, why'd I rewrite my blog in Go? It wasn't just for the fun of it. Go will let me do some more creative things with my blog in the future, like:
There is 1 comment on this page. Add yours.
So responsive. I like it. Will you marry me?
0.0103s
.