Skip to content

Commit

Permalink
Error for missing breadcrumbs (scientific-python/blog.scientific-pyth…
Browse files Browse the repository at this point in the history
…on.org#158)

* layouts/partials/breadcrumbs.html: Log an error and fail the build
if a breadcrumb is missing (i.e. if a page used in a breadcrumb has a
missing "title" field in its front matter).

This only applies to content pages which are referred to in
breadcrumbs; other pages are still allowed to not have titles.

See <scientific-python/blog.scientific-python.org#158>.
  • Loading branch information
alphapapa committed Apr 23, 2024
1 parent ac48aa5 commit 472c9c6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions layouts/partials/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<ul id="breadcrumbs" class="bd-breadcrumbs">
{{- range $index, $ := .Ancestors.Reverse }}
{{ if $index }}

{{ or .Title
(errorf "Missing breadcrumb: Page has no \"title\" field. Filename:%q"
.File.Filename) }}

<li class="breadcrumb-item"><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ else }}
<li class="breadcrumb-item breadcrumb-home"><a href="{{ .RelPermalink }}"><i class="fas fa-home"></i></a></li>
Expand Down

0 comments on commit 472c9c6

Please sign in to comment.