Skip to content

Instantly share code, notes, and snippets.

@jmooring
Last active August 3, 2023 22:09
Show Gist options
  • Save jmooring/4a5e3c0334713bf60d63089c9cda36b5 to your computer and use it in GitHub Desktop.
Save jmooring/4a5e3c0334713bf60d63089c9cda36b5 to your computer and use it in GitHub Desktop.
Hugo - Display breadcrumb navigation
{{- $currentPage := . }}
{{- with .Ancestors.Reverse }}
<nav class="breadcrumbs">
{{- range $k, $_ := . | append $currentPage }}
{{- if $k }}
<span class="breadcrumb-separator">&raquo;</span>
{{- end }}
{{- if $currentPage.Eq . }}
<a aria-current="page" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{- else }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{- end }}
{{- end }}
</nav>
{{- end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment