- {{- if (.Param "ShowBreadCrumbs")}} - - {{- $url := replace .Parent.Permalink ( printf "%s" .Site.BaseURL) "" }} - {{- $lang_url := replace $url ( printf "%s" .Lang) "" }} - - {{ i18n "home" | default "Home"}} - {{- range $index, $element := split $lang_url "/" }} - - {{- $.Scratch.Add "path" (printf "%s/" $element )}} - {{- $bc_pg := $.Site.GetPage ($.Scratch.Get "path") -}} - - {{- if (and ($bc_pg) (gt (len . ) 0))}} - {{- print " » " | safeHTML -}}{{ $bc_pg.Name }} - {{- end }} - - {{- end }} - - {{- end }} + {{- partial "breadcrumbs.html" . }} {{ .Title }} {{- if .Draft }} [draft]{{- end }} diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html new file mode 100644 index 00000000..55320892 --- /dev/null +++ b/layouts/partials/breadcrumbs.html @@ -0,0 +1,18 @@ +{{- if (.Param "ShowBreadCrumbs")}} + + {{- $url := replace .Parent.Permalink ( printf "%s" .Site.BaseURL) "" }} + {{- $lang_url := replace $url ( printf "%s" .Lang) "" }} + + {{ i18n "home" | default "Home"}} + {{- range $index, $element := split $lang_url "/" }} + + {{- $.Scratch.Add "path" (printf "%s/" $element )}} + {{- $bc_pg := $.Site.GetPage ($.Scratch.Get "path") -}} + + {{- if (and ($bc_pg) (gt (len . ) 0))}} + {{- print " » " | safeHTML -}}{{ $bc_pg.Name }} + {{- end }} + + {{- end }} + +{{- end }}