Implementing breadcrumb navigation in hugo?

@maltesa Yours is by far the simplest solution for Breadcrumb Navigation. Thank you!

I modified it a bit to exclude the homepage link as I needed to give it a different name than the title.

Here is the modified snippet.

<span class="breadcrumb">
<a href="/">Custom Homepage Title</a>
  {{ template "breadcrumb" dict "currentPage" .Page "id" .UniqueID }}
</span>

<!-- templates -->
{{ define "breadcrumb" }}
 {{ if .currentPage.Parent }}
 {{ if ne .currentPage.Parent .IsHome }}
    {{ template "breadcrumb" dict "currentPage" .currentPage.Parent }}
  {{ end }}
    {{ if eq .id .currentPage.UniqueID }}
      {{ .currentPage.Title }}
    {{ else }}
      <a href="{{ .currentPage.URL }}">{{ .currentPage.Title }}</a> >
    {{ end }}
{{ end }}
{{ end }}
1 Like