Interactive code examples in documentation?

I think the documentation for Hugo is pretty brilliant, but more is a powerful word.

Would it be possible to have interactive code examples in the documenation?

My frontend brain says this would be nigh on impossible but I thought it would be interesting to put it out there :slightly_smiling_face:

1 Like

This kind of widgets are always interesting for programming languages.

But Hugo is mainly a templating platform, I’m curious as to what kind of interaction your are referring too? Do you have an example?

The same kind of interaction really, as in you change the values, press enter and see how the changes are reflected in the outputted result.

I find the hardest part of Hugo is wrangling the templating: if there was an interactive element, you could see for example how menus are generated

menu: ["main", "footer"]

Maybe one big fat interactive example website?? (thinking aloud…)

Interesting idea! :slight_smile:

But if I put on my ‘pessimistic thinking hat’, I’d be concerned that we only add to confusion for newcomers: Why does my example menu work in the playground but not on my site? That would give us two websites to ‘debug’: the repository and the code that’s in the playground.

Problem of course is that Hugo’s strength (its flexibility) becomes a disadvantage in a playground, since that playground likely always differ from someone’s local website. Or not?

1 Like

The pessimistic hat is a handy hat to have around! :slightly_smiling_face:

If there was one interactive playground website, I would imagine it to have the “most common use case scenarios” – a couple of menus, blog posts, categories, tags, a handful of pages etc. I think this would help beginners get off the ground. Then (blue sky hat on), when a user interacts with the playground website, a new instance of it is spun up just for that user.

Why does my example menu work in the playground but not on my site?

This question is much easier to answer if you actually have a working playground you can play with and break yourself.

All big conjecture but I do like the idea!

1 Like