I want to use JSON to markup my pages with schema.org markup, but I have all kinds of pages (e.g. About, Contact, Tutorial and Category pages).
About page = schema.org/AboutPage
Contact page = schema.org/ContactPage
Category pages, sitemap.html, etc = schema.org/WebPage
Tutorial pages = schema.org/TechArticle
How can I create that?
I already created a site-schema.html file in the /layouts/partials/ folder - which looks like this:
{{ if .IsHome -}}
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"WebSite",
"name":"",
"url":"",
"description":"",
"sameAs":[
"",
"",
""
]}
</script>
{{- else if .IsPage -}}
<script type="application/ld+json">{
"@context":"http://schema.org",
"@type":"TechArticle",
"headline":"{{ .Title }}",
"description":"{{ .Description }}",
"image":"{{ range $i, $e := .Params.images }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}",
"datePublished":"{{.PublishDate}}"
},}
</script>
{{- end }}
and in the header.html file I added the following code:
{{ partial "site-schema.html" . }}
But that will give the home page its correct schema markup, but will give all other pages the schema.org/TechArticle markup.
And on some pages I also have embedded YouTube videos:
<script type="application/ld+json">{
"@context":"http://schema.org",
"@graph":[{
"@type":"TechArticle",
"headline":"",
"description":"",
"image":"",
"datePublished":"2018-02-03"},{
"@type":"VideoObject",
"name":"",
"description":"",
"thumbnailUrl":"",
"uploadDate":"2018-02-03",
"embedUrl":""},{
"@type":"VideoObject",
"name":"",
"description":"",
"thumbnailUrl":"",
"uploadDate":"2018-02-03",
"embedUrl":""
}]}</script>
So how can I do this?