<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Building Brege.org on brege.org</title>
    <link>https://brege.org/series/building-brege.org/</link>
    <description>Recent content in Building Brege.org on brege.org</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright (c) 2016-2026 Wyatt Brege</copyright>
    <lastBuildDate>Sun, 12 Apr 2026 21:44:40 -0400</lastBuildDate>
    <atom:link href="https://brege.org/series/building-brege.org/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>New way forward for deploying brege.org</title>
      <link>https://brege.org/post/new-way-forward-for-deploying-brege.org/</link>
      <pubDate>Tue, 18 Oct 2016 16:35:01 -0700</pubDate>
      <guid>https://brege.org/post/new-way-forward-for-deploying-brege.org/</guid>
      <description>&lt;p&gt;ssh&amp;rsquo;ing into my Digital Ocean droplet has become rather annoying for maintaining this website.  Particularly annoying is dealing with images on two different filesystems.  In the &lt;a href=&#34;https://github.com/brege/brege.org/blob/master/README.md&#34;&gt;README&lt;/a&gt; (commit &lt;a href=&#34;https://github.com/brege/brege.org/commit/1a0ee5a1a946bf5ee574a4593e4e6b22d35607e3&#34;&gt;1a0ee5a&lt;/a&gt;), I describe the steps I have been doing to publish an article to &lt;a href=&#34;https://brege.org&#34;&gt;https://brege.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I tried implementing &lt;a href=&#34;https://www.digitalocean.com/community/tutorials/how-to-deploy-a-hugo-site-to-production-with-git-hooks-on-ubuntu-14-04&#34;&gt;this method&lt;/a&gt;, but it is very long and requires many modifications to the post-receive hook to get it working on a per-user basis.&lt;/p&gt;
&lt;p&gt;Here I outline a way to do this in a more conservative manner.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>ssh&rsquo;ing into my Digital Ocean droplet has become rather annoying for maintaining this website.  Particularly annoying is dealing with images on two different filesystems.  In the <a href="https://github.com/brege/brege.org/blob/master/README.md">README</a> (commit <a href="https://github.com/brege/brege.org/commit/1a0ee5a1a946bf5ee574a4593e4e6b22d35607e3">1a0ee5a</a>), I describe the steps I have been doing to publish an article to <a href="https://brege.org">https://brege.org</a>.</p>
<p>I tried implementing <a href="https://www.digitalocean.com/community/tutorials/how-to-deploy-a-hugo-site-to-production-with-git-hooks-on-ubuntu-14-04">this method</a>, but it is very long and requires many modifications to the post-receive hook to get it working on a per-user basis.</p>
<p>Here I outline a way to do this in a more conservative manner.</p>
<h2 id="installation-on-development-machine">Installation on development machine</h2>
<ol>
<li>On a development laptop, <a href="https://getfedora.org/">Fedora</a>, I installed <a href="https://golang.org/">Go</a> and <a href="https://gohugo.io">Hugo</a> via</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo dnf install golang
</span></span><span class="line"><span class="cl">mkdir -p ~/build/go
</span></span><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">GOPATH</span><span class="o">=</span><span class="nv">$HOME</span>/build/go
</span></span><span class="line"><span class="cl">go get -v github.com/spf13/hugo
</span></span></code></pre></div><ol start="2">
<li>Clone repository</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">cd</span> ~/build/
</span></span><span class="line"><span class="cl">git clone git://github.com/brege/brege.org.git
</span></span></code></pre></div><h2 id="new-workflow-for-publishing-an-article">New workflow for publishing an article</h2>
<ol>
<li>I once again use Hugo to create my article</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">cd</span> ~/build/brege.org
</span></span><span class="line"><span class="cl">hugo new post/new-way-forward-for-deploying-brege.org.md
</span></span></code></pre></div><ol start="2">
<li>
<p>Add content, run <code>hugo server</code>, then preview http://localhost:1313 in a browser to determine what needs to be edited.  The cool thing about this is you can edit/add a file while the test server is running. You don&rsquo;t even need to refresh the browser page whenever you save the file!</p>
</li>
<li>
<p>Run <code>rm -r public/ ; hugo</code> to remove the old and create the new <code>public/</code> directory on the development machine.</p>
</li>
<li>
<p>Ship the changes to the production server (DO droplet) with rsync:</p>
</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">rsync -avP --delete --exclude<span class="o">=</span><span class="s2">&#34;.well-known&#34;</span> public/ brege.org:/usr/share/nginx/brege.org/
</span></span></code></pre></div><p>The new article will now show up on the <a href="https://brege.org/post/new-way-forward-for-deploying-brege/">https://brege.org/post/new-way-forward-for-deploying-brege/</a></p>
<ol start="5">
<li>Finally, commit the new article to GitHub:</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git add content/post/new-way-forward-for-deploying-brege.org.md
</span></span><span class="line"><span class="cl">git commit -m <span class="s2">&#34;Add article&#34;</span>
</span></span><span class="line"><span class="cl">git push -u origin master
</span></span></code></pre></div><p>Much nicer way to go about it.  Images and other assets can be more readily copied and modified.  I can edit a webpage on the fly before publishing layout-bugs and typos to the world (or, at least to a lesser extent).</p>]]></content:encoded>
    </item>
    <item>
      <title>brege.org now on GitHub</title>
      <link>https://brege.org/post/brege.org-now-on-github/</link>
      <pubDate>Wed, 12 Oct 2016 00:32:21 +0000</pubDate>
      <guid>https://brege.org/post/brege.org-now-on-github/</guid>
      <description>&lt;p&gt;Earlier I added the hugo source files for this website on GitHub.  Take a look!&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/brege/brege.org&#34;&gt;https://github.com/brege/brege.org&lt;/a&gt;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Earlier I added the hugo source files for this website on GitHub.  Take a look!</p>
<p><a href="https://github.com/brege/brege.org">https://github.com/brege/brege.org</a></p>
]]></content:encoded>
    </item>
    <item>
      <title>Building brege.org</title>
      <link>https://brege.org/post/building-brege-dot-org/</link>
      <pubDate>Mon, 10 Oct 2016 19:47:14 +0000</pubDate>
      <guid>https://brege.org/post/building-brege-dot-org/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;
&lt;p&gt;brege.org is deployed with the following services:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.namecheap.com/&#34;&gt;Namecheap&lt;/a&gt; - DNS Registrar&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://letsencrypt.org&#34;&gt;Let&amp;rsquo;s Encrypt&lt;/a&gt; - Free SSL certificates&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.digitalocean.com&#34;&gt;Digital Ocean&lt;/a&gt; - Droplets for $5 a month&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;brege.org makes use of the following tools:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://nginx.org&#34;&gt;Nginx&lt;/a&gt; - Fast reverse proxy&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://debian.org&#34;&gt;Debian Jessie&lt;/a&gt; - Operating system running on our DO droplet&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://gohugo.io&#34;&gt;Hugo&lt;/a&gt; - Static site generator&lt;/li&gt;
&lt;/ul&gt;</description>
      <content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p>brege.org is deployed with the following services:</p>
<ul>
<li><a href="https://www.namecheap.com/">Namecheap</a> - DNS Registrar</li>
<li><a href="https://letsencrypt.org">Let&rsquo;s Encrypt</a> - Free SSL certificates</li>
<li><a href="https://www.digitalocean.com">Digital Ocean</a> - Droplets for $5 a month</li>
</ul>
<p>brege.org makes use of the following tools:</p>
<ul>
<li><a href="https://nginx.org">Nginx</a> - Fast reverse proxy</li>
<li><a href="https://debian.org">Debian Jessie</a> - Operating system running on our DO droplet</li>
<li><a href="https://gohugo.io">Hugo</a> - Static site generator</li>
</ul>
<h2 id="hosting">Hosting</h2>
<p>First thing I did was register my domain on Namecheap.
It was around $12 to register brege.org.</p>
<p>Next bit was deciding on a hosting provider.
I gave Amazon S3 some consideration, since it&rsquo;s practically free for a static site, but after playing around with their tools it seemed far too confusing to use.
I thought I&rsquo;d try Digital Ocean.
Their tutorials on deploying various web apps have been quite helpful in previous searches, and they host good things like <a href="https://lkml.org">lkml.org</a>.
The $5 droplet service offers 512 MB RAM, 20 GB SSD, and 1 TB of bandwidth.
Good enough.</p>
<p>I selected the debian installation on the &ldquo;Create Droplet&rdquo; page and created a new ssh key:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">ssh-keygen -t rsa -b <span class="m">4096</span> -C <span class="s2">&#34;wyatt@brege.org&#34;</span>
</span></span></code></pre></div><p>I like to have a different key for each remote service I use (GitHub, Clusters, Servers, etc).
So for the bit about saving the key, I just substituted the default <code>id_rsa</code> with <code>do_rsa</code>, chose a password to unlock my key, and uploaded <code>do_rsa.pub</code> in the DO web interface.</p>
<p>This gets added to /root/.ssh/authorized_keys on your DO droplet.
I added another user on my droplet so I wouldn&rsquo;t always be logging in as root.
You can copy this key from your workstation to the user&rsquo;s home directory on your droplet via</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">ssh-copy-id -i ~/.ssh/do_rsa newuser@ip.of.my.droplet
</span></span></code></pre></div><p>DNS settings can be confusing. Setting &ldquo;Custom DNS&rdquo; in Namecheap and setting the nameservers to DO&rsquo;s nameservers was simple enough.  Setting records on namecheap is kind of annoying.  On DO it is really intuitive to set up records.</p>
<h3 id="nginx">Nginx</h3>
<p>I&rsquo;ve been using nginx on my personal home server and quite like its configuration and speed.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install nginx
</span></span></code></pre></div><p>I&rsquo;m not exactly sure what the consensus is on where your site should live in your debian install.
<code>/usr/share/nginx/</code>? <code>/var/www/</code>? The <code>html/</code> directory in either of those?
The way I treat it is that my static site will live in <code>/usr/share/nginx/brege.org/</code>.
If I want to password protect any section of my site, my <code>.htpasswd</code> will live in user <code>www-data</code>&rsquo;s home directory, <code>/var/www/</code>.
If I want to host some other site for <code>abc.brege.org</code>, it will live in <code>/usr/share/nginx/abc.brege.org/</code>.</p>
<p>I removed the default site configuration file installed on debian.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">rm /etc/nginx/sites-available/default
</span></span><span class="line"><span class="cl">rm /etc/nginx/sites-enabled/default
</span></span></code></pre></div><p>I made a new configuration file <code>/etc/nginx/sites-available/brege.org</code> with the following settings:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nginx" data-lang="nginx"><span class="line"><span class="cl"><span class="k">server</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="kn">server_name</span> <span class="s">*.brege.org</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="kn">return</span> <span class="s">http://brege.org/</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">server</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="kn">listen</span> <span class="mi">80</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="kn">listen</span> <span class="s">[::]:80</span> <span class="s">default_server</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="kn">server_name</span>  <span class="s">brege.org</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="c1"># enforce https
</span></span></span><span class="line"><span class="cl">    <span class="kn">return</span> <span class="mi">301</span> <span class="s">https://</span><span class="nv">$server_name$request_uri</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">server</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="kn">listen</span> <span class="mi">443</span> <span class="s">default</span> <span class="s">ssl</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="kn">listen</span> <span class="s">[::]:443</span> <span class="s">default_server</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="kn">root</span> <span class="s">/usr/share/nginx/brege.org</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="kn">index</span> <span class="s">index.html</span> <span class="s">index.htm</span> <span class="s">index.php</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="kn">server_name</span> <span class="s">brege.org</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="kn">ssl_certificate</span> <span class="s">/etc/letsencrypt/live/brege.org/fullchain.pem</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="kn">ssl_certificate_key</span> <span class="s">/etc/letsencrypt/live/brege.org/privkey.pem</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="kn">include</span> <span class="s">letsencrypt.conf</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="kn">location</span> <span class="s">/</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="c1"># First attempt to serve request as file, then
</span></span></span><span class="line"><span class="cl">        <span class="c1"># as directory, then fall back to displaying a 404.
</span></span></span><span class="line"><span class="cl">        <span class="kn">try_files</span> <span class="nv">$uri</span> <span class="nv">$uri/</span> <span class="p">=</span><span class="mi">404</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>You can split each <code>server{ ... }</code> block into its own config file if you like.
One redirects all <code>*.brege.org</code> requests to <code>brege.org</code>, including <code>www.brege.org</code>.
The second one redirects all requests from <a href="http://brege.org">http://brege.org</a> to <a href="https://brege.org">https://brege.org</a>.
The third is the main configuration for the site.
This is where you put reverse proxies that redirect internal ports to subdirectories on your site.</p>
<p>Link the new configuration file and restart nginx:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo ln -s /etc/nginx/sites-available/brege.org /etc/nginx/sites-enabled/
</span></span><span class="line"><span class="cl">sudo systemctl restart nginx.service
</span></span></code></pre></div><h3 id="lets-encrypt">Let&rsquo;s Encrypt</h3>
<p>In <code>/etc/nginx/letsencrypt.conf</code>, I have:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nginx" data-lang="nginx"><span class="line"><span class="cl"><span class="k">location</span> <span class="s">^~</span> <span class="s">/.well-known/acme-challenge</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="kn">alias</span> <span class="s">/var/lib/letsencrypt/.well-known/acme-challenge</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="kn">default_type</span> <span class="s">&#34;text/plain&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="kn">try_files</span> <span class="nv">$uri</span> <span class="p">=</span><span class="mi">404</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>After making any changes to your nginx configuration, restart the service:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo systemctl restart nginx.service
</span></span></code></pre></div><p>We need to generate a free SSL certificate from Let&rsquo;s Encrypt.
I followed the instructions on <a href="https://certbot.eff.org/#debianjessie-nginx">https://certbot.eff.org/#debianjessie-nginx</a> to install certbot on Debian Jessie.</p>
<p>As root, I ran</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">certbot certonly --webroot -w /usr/share/nginx/brege.org -d brege.org -d www.brege.org
</span></span></code></pre></div><p>and completed the wizard. YMWV</p>
<h3 id="hugo">Hugo</h3>
<p>Since I&rsquo;ve been getting into the habit of writing my notes and personal documentation in <a href="https://daringfireball.net/projects/markdown/">Markdown</a>, I wanted to be able to quickly copy and paste snippets to-and-from this website.
I found <a href="https://gohugo.io">Hugo</a>, which is written in <a href="https://golang.org/">Go</a>.
It is very fast to build a static website under.
Every post is written in markdown, and running the <code>hugo</code> command only takes ~50ms to generate all the html/css/js files.
No more having to fiddle with html/css/js.</p>
<p>First, the version of <a href="https://golang.org/">Go</a> required to run Hugo must be 1.5 or greater at the time of writing.
I went to <a href="https://golang.org/dl/">https://golang.org/dl/</a> and grabbed the latest release:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">cd</span> ~/
</span></span><span class="line"><span class="cl">wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz
</span></span><span class="line"><span class="cl">tar xvf go1.7.1.linux-amd64.tar.gz
</span></span><span class="line"><span class="cl">rm go1.7.1.linux-amd64.tar.gz
</span></span><span class="line"><span class="cl">sudo mv go /opt/
</span></span><span class="line"><span class="cl">sudo chown -R newuser:newuser go/
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> go/ 
</span></span></code></pre></div><p>I added the following to <code>/etc/profile</code></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span><span class="nv">$PATH</span>:/usr/local/go/bin
</span></span><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span><span class="nv">$PATH</span>:/opt/go/bin
</span></span></code></pre></div><p>Next, install Hugo via git:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">GOPATH</span><span class="o">=</span>/opt/go/bin
</span></span><span class="line"><span class="cl">go get -v github.com/spf13/hugo
</span></span></code></pre></div><p>More information available <a href="https://gohugo.io/overview/installing/">here</a>.</p>
<p>Checkout <a href="https://themes.gohugo.io/">https://themes.gohugo.io/</a> to see if there&rsquo;s a theme that you like.
I thought the <a href="https://github.com/gcushen/hugo-academic">academic theme</a> looked pretty nice.
I followed the instructions in the README.md to create my site.</p>
<p>The workflow is typically:</p>
<ol>
<li>Creating a new post</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">hugo new post/hello-world.md
</span></span></code></pre></div><ol start="2">
<li>
<p>Adding what I want to say with simple markdown format in <code>content/post/hellow-world.md</code> after the <code>+++ ... +++</code> front matter.</p>
</li>
<li>
<p>Running <code>hugo</code>, which creates all the files for your site.
It may be wise to remove the <code>public/</code> directory and the <code>/usr/share/nginx/brege.org/*</code> subdirectories to prune any orphaned articles.</p>
</li>
<li>
<p>Copying the generated <code>public/</code> folder over to the document root.</p>
</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo rsync -avP public/ /usr/share/nginx/brege.org/
</span></span></code></pre></div><ol start="5">
<li>Visit brege.org in my browser.</li>
</ol>
<p>In fact, there is probably no need to run go/hugo on my DO droplet at all.
The proper way is probably to do everything on a local machine, add a new article and check at localhost:1313, then rsync the contents of <code>public/</code> to your document root on your droplet.</p>
<p>Putting the source of this site on github might be even better.
I&rsquo;m already keeping track of my changes with a local git repository, so I might as well make it available on GitHub.  Plus it seems worth it just for the sake of writing articles locally.</p>
<p><strong>Update</strong>: I am getting closer to implementing my initial thoughts here: <a href="https://brege.org/post/new-way-forward-for-deploying-brege/">https://brege.org/post/new-way-forward-for-deploying-brege/</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>
