article.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {{- $page := .page }}
  2. {{ $summary := .summary }}
  3. {{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }}
  4. {{/* Get schema type. */}}
  5. {{ $schema := "Article" }}
  6. {{ if eq $page.Type "post" }}
  7. {{ $schema = "BlogPosting" }}
  8. {{ end }}
  9. {{ $author := partial "functions/get_author_name" $page }}
  10. {{ $publisher := site.Params.org_name | default site.Title }}
  11. {{ $logo_url := partial "functions/get_logo_url" $page -}}
  12. <script type="application/ld+json">
  13. {
  14. "@context": "https://schema.org",
  15. "@type": {{$schema}},
  16. "mainEntityOfPage": {
  17. "@type": "WebPage",
  18. "@id": {{$page.Permalink}}
  19. },
  20. "headline": {{$page.Title}},
  21. {{ if $featured_image }}
  22. "image": [
  23. {{$featured_image.Permalink}}
  24. ],
  25. {{end}}
  26. "datePublished": {{ $page.PublishDate.Format "2006-01-02T15:04:05Z07:00" }},
  27. "dateModified": {{ $page.Lastmod.Format "2006-01-02T15:04:05Z07:00" }},
  28. {{with $author}}
  29. "author": {
  30. "@type": "Person",
  31. "name": {{.}}
  32. },
  33. {{end}}
  34. "publisher": {
  35. "@type": "Organization",
  36. "name": {{$publisher}},
  37. "logo": {
  38. "@type": "ImageObject",
  39. "url": {{$logo_url}}
  40. }
  41. },
  42. "description": {{$summary}}
  43. }
  44. </script>