I have a site that has both regular content and a blog to go with it. I have the following breadcrumb navigation:
<nav class='googly-navigation googly-navigation-top googly-navigation-left'>
{{ $scratch := .Scratch }}
{{ if ne .RelPermalink "/" }}
{{ $scratch.Add "links" (slice .RelPermalink) }}
{{ $scratch.Add "titles" (slice .Title) }}
{{ end }}
{{ range where .Site.Pages "RelPermalink" .Params.parent }}
{{ $scratch.Add "links" (slice .RelPermalink) }}
{{ $scratch.Add "titles" (slice .Title) }}
{{ range where .Site.Pages "RelPermalink" .Params.parent}}
{{ $scratch.Add "links" (slice .RelPermalink) }}
{{ $scratch.Add "titles" (slice .Title) }}
{{ range where .Site.Pages "RelPermalink" .Params.parent}}
{{ $scratch.Add "links" (slice .RelPermalink) }}
{{ $scratch.Add "titles" (slice .Title) }}
{{ range where .Site.Pages "RelPermalink" .Params.parent}}
{{ $scratch.Add "links" (slice .RelPermalink) }}
{{ $scratch.Add "titles" (slice .Title) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ $scratch.Add "links" (slice "/") }}
{{ $scratch.Add "titles" (slice "Home Page") }}
{{ $links := ($scratch.Get "links") }}
{{ $titles := ($scratch.Get "titles") }}
{{ range $n := (seq (sub (len $links) 1) 0)}}
{{ $href := index $links $n }}
{{ $title := index $titles $n }}
{{ $color := (first 6 (sha256 $title)) }}
<a href='{{ $href }}'
title='{{ $title }}'
aria-label='{{ $title }}'>
{{ if eq $n (sub (len $links) 1) }}
{{ partial "googly.svg" "5fb5b4" }}
{{ else }}
{{ partial "googly.svg" $color }}
{{ end }}
</a>
{{ end }}
</nav>
{{ printf "%+v" $links }}
<br>
{{ printf "%+v" $titles }}
On a page that isn’t a blog post, this outputs the following printf bits:
[/qs/making-a-font/ /qs/ /qs/ / /]
[Making a Quikscript Font Qs Quikscript Resources frogorbits.com home Home Page]
When I use .Site.Pages repeatedly in my nested ranges I get entreis in $links and $titles that shouldn’t be there, like the one with a link of /qs/ but a title of “Qs”. When I use .Site.RegularPages I don’t get this duplicate page, but then my breadcrumbs don’t work on single-blog-post pages in /blog/.
In blog-post pages, there is a breadcrumb permalink to the post (/blog/yada-yada/) and a link to the home page (/), but no link to the blog itself (/blog/).
How can I ensure that Hugo doesn’t make “qs” pages that aren’t really there? I did ack -i qs
and it didn’t seem to declare anything that would make a special type of page.