I am using Hugo to generate my static site. I have to inspect the value of a variable in Hugo to make sure I get expected results. Consider the following in index.html:

{{ $pages := .Pages }} <body> <div> {{ $pages }} </div> </body> 

What I get is:

Pages(3) 

But what I want is to see the full serialized value of the object. How to achieve it?


Attempts

I have tried:

<div> {{ print $pages }} </div> 

However still the same.

1 Answer

You have printf available, so you can try

{{ printf "%#v" $pages }} 

Hugo template debugging

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.