Snippet - partial for creating breadcrumbs (uses Bootstrap 4)

Here is a simple recursive breadcrumb. You have to modify it, but the recursive solution seems to be better…

{{ define "breadcrumb" }}
  {{ with .Parent }}
    {{ template "breadcrumb" . }}
    <a href="{{ .URL }}">{{ if .IsHome }}Home{{ else }}{{.Title}}{{ end }}</a> >
  {{ end }}
{{ end }}
{{ if not .IsHome }}
  <div class="breadcrumb">
    {{ template "breadcrumb" . }}
    {{.Title}}
  </div>
{{ end }
2 Likes