Last Breadcrumb NOT to include current level

Hello Hugo friends!

Hopefully you can help us with our breadcrumb code we have currently so it will not show the current level page of breadcrumb. We are $Scratch’in our heads!

            {{ $siteUrl := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
            {{ $.Scratch.Add "sitePath" .Site.BaseURL }}
            {{ $.Scratch.Add "siteBreadcrumbs" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) }}
            {{ range $index, $element := split $siteUrl "/" }}
            {{ $.Scratch.Add "sitePath" $element }}
            {{ $.Scratch.Add "sitePath" "/" }}
            {{ if ne $element "" }}
            {{ $.Scratch.Add "siteBreadcrumbs" (slice (dict "url" ($.Scratch.Get "sitePath") "name" . "position" (add $index 2))) }}
            {{ end }}
            {{ end }}

Hi there,

It would be easier to help you if we could test your snippet with your site context. Do you have your site in a repo somewhere we can clone?

1 Like

I wish I did have a public repo for this :confused: is the website and what I’m wanting is those breadcrumbs across the top in the hero image to not use the last link or even show it. This page, as example, shows the ‘12 Terrazzo Spaces’ in the hero and it’s a link. I’d rather just truncate the very last item in the set if such a function exists?