hugo: fix edge case causing duplicate h1 (#17959)

Some documents are missing a `title` front matter,
and instead use an H1 from the document body.
This change introduces a fix to render an external
h1 only if the front matter field is set.

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2023-08-22 11:48:51 +02:00 committed by GitHub
parent c6667b7acb
commit 1c6f0ee337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -5,7 +5,9 @@
{{ define "main" }}
{{ partial "breadcrumbs-legacy.html" . }}
<article class="prose max-w-none dark:prose-invert">
<h1>{{ .Title }}</h1>
{{ with .Title }}
<h1>{{ . }}</h1>
{{ end }}
{{ .Content }}
</article>
{{ end }}

View File

@ -5,7 +5,9 @@
{{ define "main" }}
{{ partial "breadcrumbs-legacy.html" . }}
<article class="prose max-w-none dark:prose-invert">
<h1>{{ .Title }}</h1>
{{ with .Title }}
<h1>{{ . }}</h1>
{{ end }}
{{ .Content }}
</article>
{{ end }}