The Pulsar Cafe    ·

Anatomy of a Blog

It has probably never been easier to publish your own content on the web. I think lots of people know this, and I think when it comes down to it most people would say it’s a good thing that the world is so connected and that ideas and problems and solutions can flow so quickly across such large physical distances. But it seems to me this is understood as a general good. Not something I might actually take advantage of outside of scanning some news feed whenever my brain finds a few free cycles.

Certainly, there are people taking advantage of this state of affairs. But most of the current conversation happens on Big Social Media, where both topic and method of discussion generally fail to meet reasonable standards. Sometimes I daydream of a world where cooperative discussion and invested learning happens on a distributed network of independent blogs. And not just in an unknown corner of the internet. No, in this world most people care about AI alignment1, have read The Sequences, or at the very least, realize why Bayes’ Theorem is important.

I may well live to see this day. Until then, rest assured you can rely on The Pulsar Cafe for mildly interesting, overly technical posts about hacking and math, with the possiblity of short fiction here and there.

Anyway, here’s how I write, host, and publish my content.

Hugo

I use Hugo to build my blog. It’s great for my use case: write blog posts, not website code. I do enough of that at work.

On a Mac, you can get up and running with Hugo in five commands:2

$ brew install hugo
$ hugo new site pulsarcafe
$ cd pulsarcafe
$ hugo new posts/welcome.md
$ hugo server -D

And your blog is available at localhost:1313. Edit the markdown files in a text editor,3 and see real time changes as the hugo server updates every time you save.

When you’re satisfied, build the site into a public/ directory with the hugo command.

Amazon S3

I tried for some time hosting my blog on an EC2 via the Apache http server. After a while I decided that was too much friction. It’s not a lot of friction, once you get comfortable with the Apache config. But there was still the possibility that maintaining my blog would require me to be a sysadmin. And so, while I enjoy hacking *nix boxes, I decided I didn’t want to have to do so for a blog site.

At this point my mind suggested to me that you can probably host a static website on Amazon S3. Some documentation that was just a google search away confirmed this. And it took me about an hour and a half to go from zero to hosting pulsarcoffee.com in an S3 bucket.

Normally I would include a step-by-step guide so that readers could replicate this setup, but I think linking to Amazon’s docs is as good or better. Most of the AWS documentation is exceptional, in my opinion.

Google Domains

I registered pulsarcoffee.com with Google Domains. I found out about Google Domains from a startup I worked for during my senior year of college, and they’re the only domain name registrar I have ever used. But, it’s incredibly easy to search for and buy a domain name from them, so I’ve also never had a reason to go elsewhere.

In the process of setting up domain routing with Amazon’s Route53, you’ll have to specify custom DNS servers through the Google Domains interface, but they make it easy to do so.

Route53

Route53 is the service Amazon provides for doing domain name routing and aliasing and all that other stuff that’s related to pointing names to IP addresses. There’s not much I can say about Route53 that isn’t included in the static web hosting guide I linked above. I’m including this section because Route53 is another top-level component in my blog architecture.

Disqus

I want feedback on what I write. I want to talk to people who are interested in what I’m interested in. I want to learn from people who know more about what I’m interested in than I do. Disqus seems to provide a platform for all of that.4

Edit (February 17, 2018)

The info below about how to set up comments for Hugo is not correct. I only realized this when I took the time to actually test posting a comment. Oops. Turns out there is a much simpler way of setting up comments:

After signing up for Disqus, set the variable disqusShortname in the config file for the site. This article on the Disqus site explains how to find the shortname associated with your site.

For example, the line in my config file is:

disqusShortname = "pulsarcoffee-com"

After setting that, open the single post template and add the line

{{ template "_internal/disqus.html" . }}

wherever you’d like comments to appear.

Below this line are the old, and incorrect, instructions for setting up Disqus comments with Hugo.


After signing up for Disqus, I put this in a disqus.html file in the partials folder of my Hugo site.

<div id="disqus_thread"></div>
<script>

/**
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/

var disqus_config = function () {
this.page.url = '{{ .Site.BaseURL }}';
this.page.identifier = '{{ .Title }}';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://pulsarcoffee-com.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

Then, in the single.html file in layouts/_default/ of the theme I’m using, I put

{{ partial "disqus.html" . }}

right above the footer.

Just like that, comments!

The End

If you want to be writing and hosting your own content online, I hope this post helped you out in some way. Drop me a line in the comments if you have anything to add! :)



1: Heck, maybe in this world the alignment problem is solved.

2: Assuming you have Homebrew. At this point, I don’t know what the audience of The Pulsar Cafe looks like, but I feel ok assuming those among that audience running Macs will already have Homebrew.

3: I use emacs.

4: No one has commented on my site yet, so I don’t have empirical evidence for this.

comments powered by Disqus