<?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>Hugo on brege.org</title>
    <link>https://brege.org/tags/hugo/</link>
    <description>Recent content in Hugo on brege.org</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright (c) 2016-2026 Wyatt Brege</copyright>
    <lastBuildDate>Sun, 12 Apr 2026 21:45:09 -0400</lastBuildDate>
    <atom:link href="https://brege.org/tags/hugo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Les Miserables</title>
      <link>https://brege.org/post/les-miserables-graph-search/</link>
      <pubDate>Sat, 24 Dec 2022 05:30:47 -0500</pubDate>
      <guid>https://brege.org/post/les-miserables-graph-search/</guid>
      <description>A network graph of character connections from one of my favorite books
and authors of all time, Victor Hugo&amp;rsquo;s Les Miserables.</description>
      <content:encoded><![CDATA[<p><em>Les Miserables is one of my favorite books.  I read most of the original translation on a train ride to Portland, OR from Chicago, IL back in 2008 and enjoyed the remainder on the return trip back East.  It taught me compassion: when Valjean places the coin in Cosette&rsquo;s shoe.  Father Christmas always misses her.  There was an earlier passage of a man stepping on a coin in front of her, while she swept dressed in rags.</em></p>
<p>The graph may take a moment to load.</p>
<p>



<style>
  #network { height: 60vh; }   
</style>

<div id="network" data-nodes-path=data/nodes.json data-edges-path=data/edges.json></div>

<script src="https://visjs.github.io/vis-network/standalone/umd/vis-network.min.js"></script>
<script src="js/lesmis-network.js"></script>



<link rel="stylesheet" href="/css/search-bar.css">
<div id="searchbox">
  <div id="search-form" data-search-path=data/nodes.json>
    <input id="search-input" autofocus placeholder="Search.." aria-label="search" type="search" autocomplete="off">
  </div>
  <div id="search-results-container" aria-label="search results"></div>
</div>
<script src="/js/search-plots.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/3.4.6/fuse.min.js" ></script>

</p>
<p>The search bar is the major addition to the graphing methods.
Nodes can be clicked and added to a subgraph builder.
You can continue to search for new node members in the search bar
(which has a rudimentary autofill that&rsquo;s a straight json query)
and clicking on them will add them to the builder.
Simultaneously, the graph will reduce to a graph containing only
all nodes with edges linked to nodes in the builder.</p>
<p>Items can be removed from the builder either by clicking the little builder tabs or re-clicking the node.  Clearing the builder bar completely will redraw the whole graph.</p>
<p>Testing and development was done on the mini pesto data set I made for <a href="/post/what-is-pesto/">What is Pesto?</a>.  Recipe builder coming soon(!)</p>
<p>Please email me at <a href="mailto:wyatt@brege.org">wyatt@brege.org</a> with any questions.</p>
<p>Dataset can be found here:</p>
<ul>
<li><a href="data/nodes.json"><code>nodes.json</code></a></li>
<li><a href="data/edges.json"><code>edges.json</code></a></li>
</ul>
<blockquote>
<p>Lingering annoyances:</p>
<ul>
<li>Slow</li>
<li>Javascript needs clean up</li>
<li>I have great fear running this on my 700x3000 dataset..</li>
</ul>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>Network Graphs with Images</title>
      <link>https://brege.org/post/network-graphs-with-images/</link>
      <pubDate>Wed, 21 Dec 2022 02:15:04 -0500</pubDate>
      <guid>https://brege.org/post/network-graphs-with-images/</guid>
      <description>A followup to the Network Graphs in Hugo post, this time with avatars for
the nodes.</description>
      <content:encoded><![CDATA[<p>This is a follow-up to the previous post <a href="/post/network-graphs-in-hugo/">Network Graphs in Hugo</a>.
I&rsquo;m feeling fruity.  These aren&rsquo;t <em>all</em> tree fruits, but a few clusters organized by tree grafting compatibility.</p>




<style>
  #mynetwork {
    background-color: #EFEBE9;  
    border-radius: 10px;
    border: 1px solid #cccccc;
    margin: 5px 0 40px 0;
  }
</style>

<div id="mynetwork" data-nodes-path=data/nodes.json data-edges-path=data/edges.json></div>

<script src="https://visjs.github.io/vis-network/standalone/umd/vis-network.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="js/fruit-network.js"></script>

<ol>
<li>
<p>Data for the network is stored in two separate JSON files in this page bundle:</p>
<ul>
<li><a href="data/nodes.json"><code>nodes.json</code></a></li>
<li><a href="data/edges.json"><code>edges.json</code></a></li>
</ul>
</li>
<li>
<p>The shortcode and post-local javascript work together:</p>
<ul>
<li><code>fruit-network.html</code></li>
<li><a href="js/fruit-network.js"><code>fruit-network.js</code></a>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-html" data-lang="html"><span class="line"><span class="cl">{{ $nodesPath := .Get &#34;nodesPath&#34; }}
</span></span><span class="line"><span class="cl">{{ $edgesPath := .Get &#34;edgesPath&#34; }}
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">style</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">  <span class="p">#</span><span class="nn">mynetwork</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">background-color</span><span class="p">:</span> <span class="mh">#f5f5f5</span><span class="p">;</span> <span class="c">/* a medium gray color */</span>
</span></span><span class="line"><span class="cl">    <span class="k">border-radius</span><span class="p">:</span> <span class="mi">10</span><span class="kt">px</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="k">border</span><span class="p">:</span> <span class="mi">1</span><span class="kt">px</span> <span class="kc">solid</span> <span class="mh">#cccccc</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="k">margin</span><span class="p">:</span> <span class="mi">5</span><span class="kt">px</span> <span class="mi">0</span> <span class="mi">40</span><span class="kt">px</span> <span class="mi">0</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 class="p">&lt;/</span><span class="nt">style</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">&#34;mynetwork&#34;</span> <span class="na">data-nodes-path</span><span class="o">=</span><span class="s">{{</span> <span class="err">$</span><span class="na">nodesPath</span> <span class="err">}}</span> <span class="na">data-edges-path</span><span class="o">=</span><span class="s">{{</span> <span class="err">$</span><span class="na">edgesPath</span> <span class="err">}}</span><span class="p">&gt;&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;https://visjs.github.io/vis-network/standalone/umd/vis-network.min.js&#34;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;https://code.jquery.com/jquery-3.6.0.min.js&#34;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;js/fruit-network.js&#34;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</span></span></code></pre></div></li>
</ul>
</li>
</ol>
<p>This will provide network graph physics where the nodes are images (all sourced from <a href="https://www.wikipedia.org/">Wikipedia</a>. Hugo template for completeness:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-markdown" data-lang="markdown"><span class="line"><span class="cl">{{&lt; fruit-network nodesPath=&#34;data/nodes.json&#34; edgesPath=&#34;data/edges.json&#34; scriptPath=&#34;js/fruit-network.js&#34; &gt;}}
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>Network Graphs in Hugo</title>
      <link>https://brege.org/post/network-graphs-in-hugo/</link>
      <pubDate>Fri, 09 Dec 2022 23:02:42 -0500</pubDate>
      <guid>https://brege.org/post/network-graphs-in-hugo/</guid>
      <description>First crack at making a simple toy network graph in Hugo.</description>
      <content:encoded><![CDATA[<p>This is a simple toy to see how a network graph can be added in a Hugo article.  I&rsquo;ll be testing new features on it as I learn new things.</p>




<div id="mynetwork" data-nodes-path="data/nodes.json" data-edges-path="data/edges.json">
  <script src="https://visjs.github.io/vis-network/standalone/umd/vis-network.min.js"></script>
  <script src="js/toy-network.js"></script>
</div>

<p>Relative to the root of the Hugo website directory, here&rsquo;s some basic files to make this interactive.
Note that The JSON data and CSS is added inline here to make the scope of this tutorial focus on Hugo-specific structures.</p>
<ol>
<li>
<p>The javascript file lives in this page bundle:</p>
<ul>
<li><a href="js/toy-network.js"><code>toy-network.js</code></a></li>
</ul>
</li>
<li>
<p>This file accesses data for the nodes and edges from two JSON files in this page bundle:</p>
<ul>
<li><a href="data/nodes.json"><code>nodes.json</code></a></li>
<li><a href="data/edges.json"><code>edges.json</code></a></li>
</ul>
</li>
<li>
<p>In the shortcodes directory <code>/layouts/shortcodes/</code>:</p>
<ul>
<li><code>toy-network.html</code>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-html" data-lang="html"><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">&#34;mynetwork&#34;</span> <span class="na">data-nodes-path</span><span class="o">=</span><span class="s">&#34;data/nodes.json&#34;</span> <span class="na">data-edges-path</span><span class="o">=</span><span class="s">&#34;data/edges.json&#34;</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;https://visjs.github.io/vis-network/standalone/umd/vis-network.min.js&#34;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;js/toy-network.js&#34;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</span></span></code></pre></div></li>
</ul>
</li>
<li>
<p>Do the normal way of making a post in Hugo, but invoke the shortcode within the body of your markdown:</p>
<ul>
<li><code>index.md</code>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-markdown" data-lang="markdown"><span class="line"><span class="cl">{{&lt; toy-network nodesPath=&#34;data/nodes.json&#34; edgesPath=&#34;data/edges.json&#34; scriptPath=&#34;js/toy-network.js&#34; &gt;}}
</span></span></code></pre></div></li>
</ul>
</li>
</ol>
<p>This will provide the simple network graph above.</p>
]]></content:encoded>
    </item>
    <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>
