For would be tinkerers

The first step to tinkering with your theme is to find out what you’re actually getting access to within a template. I am working on a bit of a debugging/logging package and thought I would share this as a functional way to dump the contents of $.Params into an HTML comment (I tend to do this in head.html) as well as an example of how you get stuff to show up in HTML comments in the first place.

{{- $params := $.Params -}}
{{- if eq (len $params) 0 -}}
{{- printf "<!-- $.Params = {} -->" | safeHTML -}}
{{- else -}}
  {{- $desc := "\n$.Params = {" -}}
  {{- range $key, $val := $params -}}
    {{- $desc = printf "%s\n  %s: %v" $desc $key $val -}}
  {{ end }}
  {{- $desc = printf "%s\n}\n" $desc -}}
  {{- printf "<!-- %s -->" $desc | safeHTML -}}
{{- end -}}

As an example, for this simple post with some text and an image

the generated HTML comment looks like so

<!-- 
$.Params = {
  categories: [Programming]
  date: 2021-03-28 18:46:47 -0700 -0700
  draft: false
  guid: http://Moondeer.micro.blog/2021/03/28/i-see-what.html
  images: [https://moondeer.blog/uploads/2021/fde86aaee6.jpg]
  iscjklanguage: false
  lastmod: 2021-03-28 18:46:47 -0700 -0700
  layout: post
  microblog: true
  photos: [https://moondeer.blog/uploads/2021/fde86aaee6.jpg]
  publishdate: 2021-03-28 18:46:47 -0700 -0700
  type: post
  url: /2021/03/28/i-see-what.html
}
 -->

Expanded to also dump site parameters:

{{- $desc := "\n$.Site.Params = {" -}}
{{- range $key, $val := $.Site.Params -}}
  {{- $desc = printf "%s\n  %s: %v" $desc $key $val -}}
{{ end }}
{{- $desc = printf "%s\n}" $desc -}}
{{- if eq (len $.Params) 0 -}}
  {{- $desc = printf "%s\n$.Params = {}\n" $desc -}}
{{- else -}}
  {{- $desc = printf "%s\n$.Params = {" $desc -}}
  {{- range $key, $val := $.Params -}}
    {{- $desc = printf "%s\n  %s: %v" $desc $key $val -}}
  {{ end }}
  {{- $desc = printf "%s\n}\n" $desc -}}
 {{- end -}}
{{- printf "<!-- %s -->" $desc | safeHTML -}}

and the generated HTML comment:

<!-- 
$.Site.Params = {
  description: All the latest thoughts to fall out my head.
  github_username: moonbuck
  include_conversation: true
  instagram_username: 
  itunes_author: Jason Cardwell
  itunes_category: Society & Culture
  itunes_cover: https://micro.blog/Moondeer/podcast.png
  itunes_description: Northside Hospital baby proudly indoctrinated into the radical left at the University of Georgia in the Deep South where I received a Bachelor of Arts in English while minoring in Mass Communications as well as a Bachelor of Science in Computer Science.
  itunes_email: 
  itunes_subcategory: Personal Journals
  mainSections: [2021]
  mainsections: [2021]
  paginate_categories: true
  paginate_home: true
  paginate_replies: false
  plugins_css: []
  plugins_html: []
  plugins_js: []
  site_id: 32187
  theme_seconds: 0
  twitter_username: 
}
$.Params = {
  categories: [Programming]
  date: 2021-03-28 18:46:47 -0700 -0700
  draft: false
  guid: http://Moondeer.micro.blog/2021/03/28/i-see-what.html
  images: [https://moondeer.blog/uploads/2021/fde86aaee6.jpg]
  iscjklanguage: false
  lastmod: 2021-03-28 18:46:47 -0700 -0700
  layout: post
  microblog: true
  photos: [https://moondeer.blog/uploads/2021/fde86aaee6.jpg]
  publishdate: 2021-03-28 18:46:47 -0700 -0700
  type: post
  url: /2021/03/28/i-see-what.html
}
 -->