I think I’ve stumbled over a heisenbug. I don’t think I can reproduce it reliably anymore, but I wanted to mention it in case it helps point to some sort of funny business somewhere.
I have a bunch of colored breadcrumbs across the top of my website. Each breadcrumb is supposed to have its own color based on a hash of something about the page. However, the leftmost breadcrumb — to the home page — is supposed to be a special color and special label; that’s what the {{ if eq .RelPermalink "/" }}
clause is for.
The googly.html
partial expands to something like <a href='{{.Get "href" }} title='…'><svg>…</svg></a>
.
I usually do local development with hugo serve -w
. As I was changing the .Title of (sha256 .Title) to other things like .URL and .Permalink, I noticed that the leftmost breadcrumb didn’t have its special color. Instead, it had some other color that was most likely generated from the (first 6 (sha256 .Permalink))
expression. After refreshing the page and restarting Hugo and refreshing the page, the leftmost breadcrumb had the right color, but I didn’t expect to have to go through all that trouble to, what seems to me, make {{ if eq .RelPermalink "/" }}
evaluate properly all the time.
<nav class='googly-navigation googly-navigation-top googly-navigation-left'>
{{ template "section-nav" . }}
</nav>
{{ define "section-nav" }}
{{ if .Parent }}
{{ template "section-nav" .Parent }}
{{ else if (eq .Section "blog") }}
{{ range where .Site.Pages "RelPermalink" "/blog/"}}
{{ template "section-nav" . }}
{{ end }}
{{ end }}
{{ $.Scratch.Set "href" .RelPermalink }}
{{ $.Scratch.Set "title" .Title }}
{{ $.Scratch.Set "color" (first 6 (sha256 .Permalink)) }}
{{ if eq .RelPermalink "/" }}
{{ $.Scratch.Set "color" "5fb5b4" }}
{{ $.Scratch.Set "title" "Home Page" }}
{{ end }}
{{ partial "googly.html" $.Scratch }}
{{ end }}
On a semi-related note, would it help anyone else here if hugo serve
sent “don’t cache, redownload everything” headers? Or would that just paper over deeper issues?