Samuel W. Flint

A tech and academic blog

Publishing This Website

I've recently changed how I publish my website. I had previously used the Org Publish system (see here), but I recently decided to update to use the Hugo site generator. In part, I chose to switch because the old system was slow, but I chose for several other reasons. I'll explain why first, and then talk about part of how I have things set up.

The Why

Org Publish worked, but it was slow, needed to be manually configured, and half of the logic needed to create, for instance, a posts listing and an RSS feed was hand-written, buggy and fragile. Hugo, on the other hand, is fast, configured using TOML or YAML, and can generate posts listings, RSS feeds, etc. automatically. It's also easily themeable (more so that Org is).

The Setup

Setting up Hugo was surprisingly easy. I didn't need to do too much to move my old pages over, just copy them in and add the frontmatter. There was a bit that I needed to do to configure things, but much of that was just setting options. Among those options, however, is the ever significant theme. I use Hugo Kiera, which has integration with my comments system (Disqus), and is easily configured to add posts, pages and social network links. To make managing this site easier, I have a few special scripts and shortcodes.


I self-host my site, so I use Rsync to copy the files over after the static site is generated by Hugo itself. If Hugo fails, exit, otherwise, copy the files up!



  hugo || exit
  rsync -avz public/ ${USER}@${HOST}:$DIR

  exit 0

New Post

New posts are more likely than are new pages – and to make it easy to create one in the right spot, I'll take a dashed title, get the year, create the file using hugo new and then edit it with whichever editor is default (Emacs!).


  YEAR=$(date +%Y)


  hugo new $FILENAME

Old Page Marking

I've got a lot of old pages on my blog. Some of them are kinda embarrassing, some of them are just old and superseded. I'd like to add a relatively standardized annotation at the top that says that the post is old, and may not reflect my current way of doing things, as well as link to a new page if one exists. I take a date and a new page as keyword arguments and fill them in to a simple template.

  {{ $date := .Get "date" }}
  {{ $newPage := .Get "newPage" }}

          This post is old, and may no longer reflect my current way of doing things or my current opinions.  It may eventually be deleted or removed.
          {{- if $newPage}}
          Try this instead:
          <a href="{{ ref . $newPage }}">
              {{- with .Site.GetPage $newPage }}
              {{- end -}}
          {{- end -}}
          {{ print "&nbsp;&mdash;&nbsp;" | markdownify }}
          {{- with $ }}
          {{.}}, <time datetime="{{$date}}">{{ dateFormat "Monday, July 3, 2006" $date }}</time>
          {{- end -}}