diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html b/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html index 3b0f7a0b11..f7e96d3007 100644 --- a/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html +++ b/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html @@ -26,6 +26,8 @@ {{ $title }} +{{ partial "head/jsonld.html" . }} + diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html b/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html new file mode 100644 index 0000000000..49f858bb4a --- /dev/null +++ b/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html @@ -0,0 +1,59 @@ +{{/* layouts/partials/head/jsonld.html */}} +{{/* --------------------------------------------------------------- + Render JSON‑LD only for Learning‑Path _index.md main pages +---------------------------------------------------------------- */}} +{{- if and .IsSection (eq .Params.learning_path_main_page "yes") -}} + {{/* -------- Helper : Build ISO‑8601 duration (PT30M, PT2H, …) */}} + {{- $duration := "" -}} + {{- with .Params.minutes_to_complete -}} + {{- $duration = printf "PT%dM" (int .) -}} + {{- end -}} + {{/* -------- Learning objectives & prerequisites */}} + {{- $objectives := slice -}} + {{- with .Params.learning_objectives -}} + {{- range . }}{{ $objectives = $objectives | append ( . | plainify ) }}{{ end -}} + {{- end -}} + {{- $prereqs := slice -}} + {{- with .Params.prerequisites -}} + {{- range . }}{{ $prereqs = $prereqs | append ( . | plainify ) }}{{ end -}} + {{- end -}} + {{/* -------- Collect tag‑style params into one keywords list */}} + {{- $keywords := slice -}} + {{- $tagParams := slice + "skilllevels" + "cloud_service_providers" + "armips" + "subjects" + "operatingsystems" + "tools_software_languages" + -}} + {{- range $tagParams -}} + {{- $v := index $.Params . -}} + {{- with $v -}} + {{- if reflect.IsSlice $v -}} + {{- range $v }}{{ $keywords = $keywords | append ( . | plainify ) }}{{ end -}} + {{- else -}} + {{- $keywords = $keywords | append ( $v | plainify ) -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{/* -------- Assemble JSON‑LD dict */}} + {{- $j := dict + "@context" "https://schema.org" + "@type" "Course" + "name" .Title + -}} + {{- with .Params.who_is_this_for }}{{ $j = merge $j (dict "description" ( . | plainify )) }}{{ end -}} + {{- if $duration }}{{ $j = merge $j (dict "timeRequired" $duration) }}{{ end -}} + {{- with .Params.skilllevels }}{{ $j = merge $j (dict "educationalLevel" .) }}{{ end -}} + {{- with $objectives }}{{ if gt (len .) 0 }}{{ $j = merge $j (dict "teaches" .) }}{{ end }}{{ end -}} + {{- with $prereqs }}{{ if gt (len .) 0 }}{{ $j = merge $j (dict "competencyRequired" .) }}{{ end }}{{ end -}} + {{- with .Params.author }}{{ $j = merge $j (dict "author" (dict "@type" "Person" "name" .)) }}{{ end -}} + {{- if $keywords }}{{ $j = merge $j (dict "keywords" (delimit (uniq $keywords) ", ")) }}{{ end -}} + {{- with .Site.Title }}{{ $j = merge $j (dict "provider" (dict "@type" "Organization" "name" .)) }}{{ end -}} + {{/* -------- Emit into */}} + +{{- end -}} \ No newline at end of file