Spurious pages in .Site.Pages

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.

Have you tried using .Site.RegularPages instead of .Site.Pages? The latter also contains other stuff than actual content files, while .Site.RegularPages only contains, well, regular pages. :slightly_smiling:

@adiabatic Do you have repo to point me to?

I have a semi-minimized zipball. Simply unpack it and run hugo serve -w in it.

Thanks!

Points of interest:

  • layouts/partials/nav.html is where the “range where” cascade is.
  • on any given page, look at the top left for the googly breadcrumbs and all the way at the bottom for the {{ printf "%+v" $links }} bit.
  • http://localhost:1313/qs/making-a-font/ is a pretty typical three-levels-deep page. It should have three googlies up top (/, /qs/, /making-a-font/), but it has…five (the proper blue one that’s the standard link to / is covered up by one that doesn’t have any CSS set to place it to the right of the fourth).
  • http://localhost:1313/qs/ is a two-levels-deep page that has a spurious link to / in it.
  • http://localhost:1313/blog/, right now, is fine when I use .Site.Pages.
  • http://localhost:1313/blog/added-making-a-quikscript-font/ is also fine.

I’ve tried both .Site.Pages and .Site.RegularPages. Thing is, I want /blog/ in the parent chain (evidently it’s not a regular page), but I also don’t want this “qs” mystery page creeping into the chain, and I don’t know where it’s coming from. Also, I don’t want duplicate home page links getting into my parent chain like when I use .Site.Pages.