mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-11-17 13:25:57 -06:00
Add basic schema.org data
This commit is contained in:
parent
7a73432238
commit
1f080d9092
@ -33,6 +33,7 @@
|
||||
{{ partial "opengraph.html" . }}
|
||||
{{ partial "twitter_cards.html" . }}
|
||||
{{ partial "schema.html" . }}
|
||||
{{ partial "seo_schema.html" . }}
|
||||
|
||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
|
||||
|
51
layouts/partials/seo_schema.html
Normal file
51
layouts/partials/seo_schema.html
Normal file
@ -0,0 +1,51 @@
|
||||
{{/* See https://github.com/spech66/hugo-best-practices#add-a-schemaorg-partial */}}
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context" : "http://schema.org",
|
||||
"@type" : "BlogPosting",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "{{ .Site.BaseURL }}"
|
||||
},
|
||||
"articleSection" : "{{ .Section }}",
|
||||
"name" : "{{ .Title }}",
|
||||
"headline" : "{{ .Title }}",
|
||||
// "description" : "{{ if .Description }}{{ .Description }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ end }}{{ end }}",
|
||||
"description" : "{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}",
|
||||
"inLanguage" : "{{ .Lang }}",
|
||||
{{ with .Params.authors -}}
|
||||
"author" : [
|
||||
{{ $len := len . }}
|
||||
{{ range $i, $author := . -}}
|
||||
{{ $url := (printf `authors/%s` ($author | anchorize)) -}}
|
||||
{
|
||||
"@type": "Person",
|
||||
"name": "{{ $author }}",
|
||||
"url": "{{ $url | absLangURL }}",
|
||||
{{ with ($.Site.GetPage $url) -}}
|
||||
"description": "{{ with .Description }}{{ . | plainify }}{{ end }}"
|
||||
{{ end -}}
|
||||
{{ if eq (add $i 1) $len -}}
|
||||
}
|
||||
{{ else }}
|
||||
},
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
],{{ end }}
|
||||
|
||||
{{ $images := $.Resources.ByType "image" -}}
|
||||
{{ $featured := $images.GetMatch "*feature*" -}}
|
||||
{{ if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||
{{ with $featured -}}
|
||||
"image": "{{ .Permalink }}",
|
||||
{{ end }}
|
||||
|
||||
"copyrightYear" : "{{ .Date.Format "2006" }}",
|
||||
"datePublished": "{{ .Date | safeHTML }}",
|
||||
"dateModified" : "{{ .Lastmod | safeHTML }}",
|
||||
"url" : "{{ .Permalink }}",
|
||||
"wordCount" : "{{ .WordCount }}",
|
||||
"keywords" : [ {{ if isset .Params "tags" }}{{ range .Params.tags }}"{{ . }}",{{ end }}{{ end }} "Blog" ]
|
||||
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user