Poop Sheet

Data

Hugo allows data in a variety of formats to sourced from several different places.

Global data is typically stored in the /data subdirectory.

Local data uses .Resources.Get which reads files in the current bundle, not be confused with resources.Get which fetches global resources.

JSON unmarshal and remarshal

  {{ $schema := dict }}
  {{ with .Resources.Get "schema.json" }}
    {{ with . | transform.Unmarshal }}
      {{ $schema = . }}
    {{ end }}
  {{ end }}
  <pre>{{ transform.Remarshal "json" $schema }}</pre>

JSON types once marshalled

Object
map[string]interface {} Can be tested with reflect.IsMap
Array
[]interface {} Can be tested with reflect.IsSlice
String
string
Number
float64
Null
nil