diff --git a/exampleSite/content/docs/guide/organize-files.md b/exampleSite/content/docs/guide/organize-files.md index cef0e51..e26b00d 100644 --- a/exampleSite/content/docs/guide/organize-files.md +++ b/exampleSite/content/docs/guide/organize-files.md @@ -180,9 +180,17 @@ This would now generate the following breadcrumbs: Documentation > Guide > Foo Bar ``` -### Hiding Breadcrumbs +### Enabling and Disabling Breadcrumbs -You can hide breadcrumbs completely from a page by specifying `breadcrumbs: false` in its front matter: +Whether breadcrumbs are enabled, or disabled, by default for a page, is determined by its [content type](https://gohugo.io/quick-reference/glossary/#content-type) and [page kind](https://gohugo.io/quick-reference/glossary/#page-kind): + +| Content Type | Section | Page | +|:----------------|:--------:|:----------| +| `docs` | Enabled | Enabled | +| `blog` | Disabled | Enabled | +| Any other type | Disabled | Disabled | + +You can override these defaults on a page by setting `breadcrumbs` in its front matter: ```yaml {filename="content/docs/guide/organize-files.md"} --- @@ -191,6 +199,18 @@ title: Organize Files --- ``` +Similarly you can use [cascade](https://gohugo.io/content-management/front-matter/#cascade-1) to override the defaults on a page and its decendents: + +```yaml {filename="content/portfolio/_index.md"} +--- +title: "Portfolio" + +cascade: + params: + breadcrumbs: true +--- +``` + ## Configure Content Directory By default, the root `content/` directory is used by Hugo to build the site. diff --git a/layouts/_partials/breadcrumb.html b/layouts/_partials/breadcrumb.html index 7dcc209..27be23d 100644 --- a/layouts/_partials/breadcrumb.html +++ b/layouts/_partials/breadcrumb.html @@ -1,6 +1,8 @@ -{{- if (default true .Params.breadcrumbs) }} +{{- $page := .page -}} +{{- $enable := .enable -}} +{{- if (default $enable $page.Params.breadcrumbs) -}}
- {{- range .Ancestors.Reverse }} + {{- range $page.Ancestors.Reverse }} {{- if not .IsHome }}
{{- partial "utils/title" . -}} @@ -9,7 +11,7 @@ {{ end -}} {{ end -}}
- {{- partial "utils/title" . -}} + {{- partial "utils/title" $page -}}
{{ end -}} diff --git a/layouts/blog/list.html b/layouts/blog/list.html index f86061b..da04445 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -4,6 +4,7 @@ {{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
+ {{ partial "breadcrumb.html" (dict "page" . "enable" false) }}
{{ if .Title }}

{{ .Title }}

{{ end }}
{{ .Content }}
diff --git a/layouts/blog/single.html b/layouts/blog/single.html index 66222ed..7a5b870 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -4,7 +4,7 @@ {{ partial "toc.html" . }}
- {{ partial "breadcrumb.html" . }} + {{ partial "breadcrumb.html" (dict "page" . "enable" true) }} {{ if .Title }}

{{ .Title }}

{{ end }}
{{- with $date := .Date }}{{ partial "utils/format-date" $date }}{{ end -}} diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 3c80126..a8795cb 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -4,7 +4,7 @@ {{ partial "toc.html" . }}
- {{ partial "breadcrumb.html" . }} + {{ partial "breadcrumb.html" (dict "page" . "enable" true) }}
{{ if .Title }}

{{ .Title }}

{{ end }} {{ .Content }} diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 3c80126..a8795cb 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -4,7 +4,7 @@ {{ partial "toc.html" . }}
- {{ partial "breadcrumb.html" . }} + {{ partial "breadcrumb.html" (dict "page" . "enable" true) }}
{{ if .Title }}

{{ .Title }}

{{ end }} {{ .Content }} diff --git a/layouts/list.html b/layouts/list.html index 653f6f1..55e7825 100644 --- a/layouts/list.html +++ b/layouts/list.html @@ -4,6 +4,7 @@ {{ partial "toc.html" . }}
+ {{ partial "breadcrumb.html" (dict "page" . "enable" false) }}
{{ if .Title }}

{{ .Title }}

{{ end }} {{ .Content }} diff --git a/layouts/single.html b/layouts/single.html index fe9f338..a9e8ac5 100644 --- a/layouts/single.html +++ b/layouts/single.html @@ -4,6 +4,7 @@ {{ partial "toc.html" . }}
+ {{ partial "breadcrumb.html" (dict "page" . "enable" false) }}
{{ if .Title }}

{{ .Title }}

{{ end }}