Skip to content

Instantly share code, notes, and snippets.

@Lego2012
Created January 29, 2019 08:40
Show Gist options
  • Select an option

  • Save Lego2012/b123fdee0c586f770ddd3e21a6217513 to your computer and use it in GitHub Desktop.

Select an option

Save Lego2012/b123fdee0c586f770ddd3e21a6217513 to your computer and use it in GitHub Desktop.
Hugo: Partial for creating breadcrumbs
{{ 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 }}

Put your partial code in /layouts/partials/breadcrumb.html.

Then use {{ partial "breadcrumb.html" . }} in any layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment