hugo/docs/content/en/troubleshooting/inspection.md
Bjørn Erik Pedersen 61a286595e
Some checks are pending
Test / test (1.23.x, ubuntu-latest) (push) Waiting to run
Test / test (1.23.x, windows-latest) (push) Waiting to run
Test / test (1.24.x, ubuntu-latest) (push) Waiting to run
Test / test (1.24.x, windows-latest) (push) Waiting to run
Merge commit 'b3d87dd0fd'
2025-04-24 10:23:16 +02:00

1.1 KiB

title linkTitle description categories keywords
Data inspection Inspection Use template functions to inspect values and data structures.

Use the debug.Dump function to inspect a data structure:

<pre>{{ debug.Dump .Params }}</pre>
{
  "date": "2023-11-10T15:10:42-08:00",
  "draft": false,
  "iscjklanguage": false,
  "lastmod": "2023-11-10T15:10:42-08:00",
  "publishdate": "2023-11-10T15:10:42-08:00",
  "tags": [
    "foo",
    "bar"
  ],
  "title": "My first post"
}

Use the printf function (render) or warnf function (log to console) to inspect simple data structures. The layout string below displays both value and data type.

{{ $value := 42 }}
{{ printf "%[1]v (%[1]T)" $value }} → 42 (int)

{{< new-in 0.146.0 />}}

Use the templates.Current function to visually mark template execution boundaries or to display the template call stack.