breadcrumb: fix Google Search Console errors #1026
Some checks are pending
docs-build-deployment / Run deploy (push) Waiting to run
docs-build / Run build (push) Waiting to run

home page did not generate schema info when disableTermBreadcrumbs=true
was set;
now we are always generating the information but hide them from the viewer
if necessary
This commit is contained in:
Sören Weber 2025-02-16 21:29:54 +01:00
parent de59e6700a
commit 0dd98363fb
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
3 changed files with 9 additions and 7 deletions

View file

@ -52,7 +52,7 @@
{{- $showBreadcrumb := (and (not .Params.disableBreadcrumb) (not .Site.Params.disableBreadcrumb)) }}
{{- if $showBreadcrumb }}
<ol class="topbar-breadcrumbs breadcrumbs highlightable" itemscope itemtype="http://schema.org/BreadcrumbList">
{{- partial "breadcrumbs.html" (dict "page" .) }}
{{- partial "breadcrumbs.html" (dict "page" . "schema" true) }}
</ol>
{{- else }}
<span class="topbar-breadcrumbs highlightable">

View file

@ -8,9 +8,6 @@
{{- $lasturl = partial "permalink.gotmpl" (dict "to" $page) }}
{{- end }}
{{- $depth := add 1 (int (partial "_relearn/pageDepth.gotmpl" (dict "page" $page))) }}
{{- if .page.Site.Params.disableRootBreadcrumb }}
{{- $depth = add $depth -1 }}
{{- end }}
{{- $breadcrumb := slice }}
{{- range seq $depth }}
{{- if $to }}
@ -33,11 +30,16 @@
{{- range $i, $e := $breadcrumbReversed }}
{{- $to := $e }}
{{- $depth = add $depth 1 }}
{{- $class := "" }}
{{- if and (eq $depth 1) site.Params.disableRootBreadcrumb }}
{{- $class = "a11y-only" }}
{{- end }}
{{- $title := partial "title.gotmpl" (dict "page" $to "linkTitle" true) }}
{{- $url := partial "permalink.gotmpl" (dict "to" $to) }}
{{- $isPage := eq $url $pageurl }}
{{- $isLast := eq $url $lasturl }}
{{- $link := and $url (not $isPage) }}
{{- printf "<li" | safeHTML }}
itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement">{{ if $link }}<a itemprop="item" href="{{ $url }}">{{end}}<span itemprop="name">{{ $title }}</span>{{ if $link }}</a>{{ end }}<meta itemprop="position" content="{{ $depth }}">{{ if not $isLast }}{{ (printf "&nbsp;%s&nbsp;" (default ">" .Site.Params.breadcrumbSeparator)) | safeHTML }}{{ end }}</li>
{{- if or $.schema (not $class) }}
<li{{ if $.schema }} itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement"{{ end }} class="{{ $class | safeHTMLAttr }}">{{ if $link }}<a{{ if $.schema }} itemprop="item"{{ end }} href="{{ $url }}">{{end}}<span{{ if $.schema }} itemprop="name"{{ end }}>{{ $title }}</span>{{ if $link }}</a>{{ end }}{{ if $.schema }}<meta itemprop="position" content="{{ $depth }}">{{ end }}{{ if not $isLast }}{{ (printf "&nbsp;%s&nbsp;" (default ">" .Site.Params.breadcrumbSeparator)) | safeHTML }}{{ end }}</li>
{{- end }}
{{- end }}

View file

@ -1 +1 @@
7.3.2+52fcb55f86db03a6d41139167165505e62cf5364
7.3.2+de59e6700a230cecc75cebb1b225fe189f0189e7