Display hugo CLI config info as an HTML table

In the spirit of “debug” threads such as Prototyping a Hugo debug bar, I thought it’d be useful to get the hugo CLI config info and display it as an HTML table. All config options are listed, which is nice because some of these aren’t accessible from the global site variable.

To use, run this command before your usual build steps:

hugo config > hugo-config-output.txt

Then add some variation of this template code:

{{ $file := readFile "hugo-config-output.txt" }}
{{ $lines := split $file "\n" }}
<table>
{{ range $lines }}
  {{ $line := split . " = " }}
  {{ $key := index $line 0 }}
  {{ $value := index $line 1 }}
  <tr>
    <td><code>{{ $key }}</code></td>
    <td><code>{{ $value }}</code></td>
  </tr>
{{ end }}
</table>

2 Likes