Not understanding debugging, need more clarity on variable data

This page recommends using printf to write variables to the screen in order to determine what values they contain.

I quite often do something very similar in PHP or JavaScript, where I dump an object using print_r(), or sometimes var_dump(), or console.log, or DevTools watch expressions, etc. These tools all provide me with valuable information.

Then there’s Go and Hugo. I try to see what’s in my $.Site.RegularPages variable and I get this:

*page.Pages{(*hugolib.pageState)(0xc000e11650), (*hugolib.pageState)(0xc000aad200), (*hugolib.pageState)(0xc0019b4a20), (*hugolib.pageState)(0xc001448ea0), (*hugolib.pageState)(0xc001c94ba0), (*hugolib.pageState)(0xc001c94de0), (*hugolib.pageState)(0xc001d77080), (*hugolib.pageState)(0xc0016dd4d0), (*hugolib.pageState)(0xc001974cc0), (*hugolib.pageState)(0xc000b0b440), (*hugolib.pageState)(0xc00092c1e0), (*hugolib.pageState)(0xc001448510), (hugolib.pageState)(0xc001448150), …

That… tells me nothing. What am I missing? How can I see what pages are contained with RegularPages?

At least with Menus, I can see there’s a menu called “main”, but not what’s actually in the main menu:


I tried looping through Menus and sending . to printf, but I get the same references.


Did you try to search prev post?
As far as I know, I think this is the best way

1 Like

Yes, I did try searching. Using both Google and the discourse search. Debugging is a fairly generic search term and even with multiple attempts using different combinations I didn’t turn up the page you linked to, thus why I posted here.

I did see another article suggesting console.log but all it did was dump the same data. It looks like the article you’ve referenced uses a slightly different tactic which may work better. I’ll give it a try.

You can use my debugprint partial from

It prints the debugged variables in a readable format as you see at the bottom of the page in


That is incredibly snazzy. I’m going to drop that in immediately and start messing around with it! Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.