fix: harden editorial brand rendering and SEO
This commit is contained in:
@@ -16,18 +16,16 @@
|
||||
"url" .Site.BaseURL
|
||||
"logo" ($brand.logoPath | absURL)
|
||||
"description" $brand.tagline
|
||||
"email" $brand.contactEmail
|
||||
"foundingDate" (printf "%d" (int $brand.foundedYear))
|
||||
"sameAs" $sameAs
|
||||
-}}
|
||||
{{- with $brand.contactEmail -}}{{- if not (in . ".example") -}}{{- $data = merge $data (dict "email" .) -}}{{- end -}}{{- end -}}
|
||||
{{- with $brand.foundedYear -}}{{- if gt (int .) 0 -}}{{- $data = merge $data (dict "foundingDate" (printf "%d" (int .))) -}}{{- end -}}{{- end -}}
|
||||
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- if or .IsHome (eq $type "FAQPage") .Params.showFaqAccordion -}}
|
||||
{{- $faqKey := printf "faq.%s" .Language.Lang -}}
|
||||
{{- $faqs := index .Site.Data $faqKey -}}
|
||||
{{- if not $faqs -}}{{- $faqs = .Site.Data.faq -}}{{- end -}}
|
||||
{{- if eq $type "FAQPage" -}}
|
||||
{{- $faqs := .Params.faqItems | default .Site.Data.faq -}}
|
||||
{{- $items := slice -}}
|
||||
{{- range $faqs -}}
|
||||
{{- $items = $items | append (dict
|
||||
@@ -36,41 +34,64 @@
|
||||
"acceptedAnswer" (dict "@type" "Answer" "text" .answer)
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- $data := dict
|
||||
"@context" "https://schema.org"
|
||||
"@type" "FAQPage"
|
||||
"mainEntity" $items
|
||||
-}}
|
||||
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
||||
{{- if gt (len $items) 0 -}}
|
||||
{{- $data := dict
|
||||
"@context" "https://schema.org"
|
||||
"@type" "FAQPage"
|
||||
"mainEntity" $items
|
||||
-}}
|
||||
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $type "Article") .Params.showRatingWidget -}}
|
||||
{{- if eq $type "Review" -}}
|
||||
{{- $authorName := .Params.authorName | default $brand.name -}}
|
||||
{{- $authorType := cond (isset .Params "authorName") "Person" "Organization" -}}
|
||||
{{- $data := dict
|
||||
"@context" "https://schema.org"
|
||||
"@type" "Review"
|
||||
"headline" (.Params.h1 | default .Title)
|
||||
"description" (.Params.description | default .Summary | plainify)
|
||||
"url" .Permalink
|
||||
"datePublished" (.Date.Format "2006-01-02")
|
||||
"dateModified" (.Lastmod.Format "2006-01-02")
|
||||
"author" (dict "@type" $authorType "name" $authorName)
|
||||
"publisher" (dict "@type" "Organization" "name" $brand.name "logo" (dict "@type" "ImageObject" "url" ($brand.logoPath | absURL)))
|
||||
"itemReviewed" (dict "@type" "Organization" "name" $brand.name)
|
||||
"itemReviewed" (dict "@type" "Organization" "name" (.Params.reviewedOrganization | default .Title))
|
||||
"reviewRating" (dict "@type" "Rating" "ratingValue" (.Params.rating | default $brand.ratingValue) "bestRating" 5 "worstRating" 1)
|
||||
-}}
|
||||
{{- if not .Date.IsZero -}}{{- $data = merge $data (dict "datePublished" (.Date.Format "2006-01-02")) -}}{{- end -}}
|
||||
{{- if not .Lastmod.IsZero -}}{{- $data = merge $data (dict "dateModified" (.Lastmod.Format "2006-01-02")) -}}{{- end -}}
|
||||
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
||||
{{- else if eq $type "Article" -}}
|
||||
{{- $authorName := .Params.authorName | default $brand.name -}}
|
||||
{{- $authorType := cond (isset .Params "authorName") "Person" "Organization" -}}
|
||||
{{- $data := dict
|
||||
"@context" "https://schema.org"
|
||||
"@type" "Article"
|
||||
"headline" (.Params.h1 | default .Title)
|
||||
"description" (.Params.description | default .Summary | plainify)
|
||||
"url" .Permalink
|
||||
"datePublished" (.Date.Format "2006-01-02")
|
||||
"dateModified" (.Lastmod.Format "2006-01-02")
|
||||
"author" (dict "@type" "Organization" "name" $brand.name)
|
||||
"mainEntityOfPage" (dict "@type" "WebPage" "@id" .Permalink)
|
||||
"author" (dict "@type" $authorType "name" $authorName)
|
||||
"publisher" (dict "@type" "Organization" "name" $brand.name "logo" (dict "@type" "ImageObject" "url" ($brand.logoPath | absURL)))
|
||||
-}}
|
||||
{{- with (.Params.image | default .Site.Params.ogImage) -}}{{- $data = merge $data (dict "image" (. | absURL)) -}}{{- end -}}
|
||||
{{- if not .Date.IsZero -}}{{- $data = merge $data (dict "datePublished" (.Date.Format "2006-01-02")) -}}{{- end -}}
|
||||
{{- if not .Lastmod.IsZero -}}{{- $data = merge $data (dict "dateModified" (.Lastmod.Format "2006-01-02")) -}}{{- end -}}
|
||||
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
||||
{{- else if and (eq $type "HowTo") .Params.howToSteps -}}
|
||||
{{- $steps := slice -}}
|
||||
{{- range .Params.howToSteps -}}
|
||||
{{- $steps = $steps | append (dict "@type" "HowToStep" "name" .name "text" .text) -}}
|
||||
{{- end -}}
|
||||
{{- if gt (len $steps) 0 -}}
|
||||
{{- $data := dict
|
||||
"@context" "https://schema.org"
|
||||
"@type" "HowTo"
|
||||
"name" (.Params.h1 | default .Title)
|
||||
"description" (.Params.description | default .Summary | plainify)
|
||||
"step" $steps
|
||||
-}}
|
||||
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user