meta_json_ld.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script type="application/ld+json">
  2. {
  3. "@context": "https://schema.org",
  4. {{ if .IsPage -}}
  5. "@type": {{ if or (eq .Section "blog") (eq .Section "post") }}"BlogPosting"{{ else }}"WebPage"{{ end }},
  6. "headline": {{ .Title }},
  7. "datePublished": {{ .Date.Format "2006-01-02T15:04:05Z07:00" }},
  8. "dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }},
  9. "url" : {{ .Permalink }},
  10. "description": {{ with (.Description | default (replaceRE "\n" " " (.Summary | truncate 170))) }}{{ . }}{{ end }},
  11. {{ with .Params.tags -}}
  12. "keywords": {{ . }},
  13. {{ end -}}
  14. {{ else -}}
  15. "@type": "WebPage",
  16. "url" : {{ .Permalink }},
  17. "name": {{ .Title }},
  18. {{ with $.Param "description" -}}
  19. "description": {{ . }},
  20. {{ end -}}
  21. {{ end -}}
  22. {{ with $.Param "image" -}}
  23. "image" : {{ . | absURL }},
  24. {{ end -}}
  25. {{ with $.Param "author" -}}
  26. "author": {
  27. "@type": "Person",
  28. "name": {{ . }}
  29. },
  30. {{ end -}}
  31. "mainEntityOfPage": {
  32. "@type": "WebPage",
  33. "@id": {{ .Site.BaseURL }}
  34. },
  35. "publisher": {
  36. "@type": "Organization",
  37. "name": {{ .Site.Title }},
  38. {{ with $.Param "icon" -}}
  39. "logo" : {
  40. "@type": "ImageObject",
  41. "url": {{ . | absURL }}
  42. },
  43. {{ end -}}
  44. "url": {{ .Site.BaseURL }}
  45. }
  46. }
  47. </script>