Last active
August 3, 2023 22:09
-
-
Save jmooring/4a5e3c0334713bf60d63089c9cda36b5 to your computer and use it in GitHub Desktop.
Hugo - Display breadcrumb navigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{- $currentPage := . }} | |
{{- with .Ancestors.Reverse }} | |
<nav class="breadcrumbs"> | |
{{- range $k, $_ := . | append $currentPage }} | |
{{- if $k }} | |
<span class="breadcrumb-separator">»</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