I threw away the blog, once more yet again

I’ve been doing some summer cleaning and finally got to the blog this week. If you read this in an actual browser instead of a feed reader you’ll notice it looks very different, but there’s a bunch of new things under the hood too that reflect what I’ve learned about writing and running a blog.

First, the new design. I’ve felt for a while that the design was getting stale, in particular I’m tired of sanserif fonts. They seem so sterile.  The new design is focused around my favorite open source serifed font Merriweather by Ebin Sorkin.  It has a lovely shape and comes in several weighs and styles.  Having real bold and italics makes words look so much nicer.  Finally the web has caught up offline typography.  For headlines I’m using Oswald, one of my go-to fonts because it just looks good with everything.

While I was changing the text I also pulled out all of the color and started over with black and white. I tried a few variations with color, asked for feedback on Twitter, and found that everyone preferred the black and white version.  I may switch to slightly off white to reduce the contrast a tad later, but the only color will be red for links and probably slight yellow for code blocks. I’m still playing around with that.

The new responsive layout is cleaner and done entirely by hand. While I use Bootstrap a lot for prototyping, stripping out the frameworks let me make the site do exactly what I want and nothing else.  The sidebar and fonts will adjust to your screen size, switching entirely to vertical if you’re on a phone.

Under the hood I’ve rewritten my blog engine again. I keep going back and forth between custom code and stock wordpress. This time I’ve switched to 100% NodeJS with all server side rendering.  I skipped the many templating languages available for Node and stuck with React.  React may seem a bit heavy for templating, but it’s actually a great choice.  It doesn’t force you to use conditionals and loop syntaxes like other systems. Instead you just use Javascript. I use JSX for describing the actual elements, but all logic is pure JS. No need to reinvent the wheel. Why did we ever invent JSPs?

In theory using React for templates would be slow, or at least slower than pure string based template engines, but in practice speed hasn’t been an issue. This is probably because I’m no longer using a database.  There’s only a few hundred posts on my site. I don’t need a real scalable database. Now I’m using a JSON file on disk that is loaded entirely into memory. I could cache the rendered pages I suppose, but I think skipping disk access gives me enough speed. I’ll only add caching if it becomes a problem later with high load.

Speaking of load, I’ve switched to keeping the fonts on Google (which cache well) and reduced the number of network requests. The site should be lightning fast.  I now do hit counting on the backend by storing an event log instead of a JS based ping. I also dropped the one display ad from the sidebar.  It slows down the site even more and only earned me about 8 bucks a month. It was an experiment in monetization that is now over. You may see it come back for future projects, but ads are forever got from this site.

Another interesting detail: I’m no longer storing the posts as HTML.  I’ve gone through three editors over the years resulting in three different file formats, each with varying levels of "semantic meaning". Now I'm storing the posts as a semantic JSON structure which loosely maps to HTML 5 but can be extended to include things that aren’t directly mapped to HTML.  Because it’s JSON I never have to worry about writing parsers again, which is awesome because I had to write three different parsers to import the older formats.  Never again.  BTW. Markdown sucks as an archival format.

As someone who’s never satisfied I wrote my own engine, templates, and editor from scratch, and I’ll probably do it again in a year. Speaking of editor, I wrote my own semantic WYSIWYM web editor that I’ll be releasing as an open source library on GitHub. I won’t link to it yet because the source is unusable by anyone but me, but when it’s done I think you’ll really like it.

So that’s what’s new.  I’m happy with the results, though there’s probably still a few bugs to be ironed out and scalability testing will begin the next time someone links to me on Hacker News.  

Thanks for reading.

Talk to me about it on Twitter

Posted July 31st, 2015

Tagged: blog