That’s not a bug and you made an uninformed assumption on where the code should go. I guess you missed, in the docs, a fundamental structure of Hugo where template code goes into templates or shortcodes in layouts, or content adapters in content. I guess the simplified nature of the example may have confused you.
mmh, ok, if you just look at that page - without a background context - you might get the impression. – but all docs pages are in context, and it does not make much sense to recap templating basics on every page.
Before you start coding you will have to get the basics and as @kijana said, if you know that the code shown contains template actions and read that part you may get the difference between content files and template files …
Shortcode
A shortcode template is used to render a component of your site. Unlike partial or content view templates, shortcode templates are called from content pages.
I dont try to be a PITA here and pretty new with hugo and trying to bring my experience back to make it better; I just started (3th day); and pretty impressed what you can do with HUGO (my work so far: Widgets for Windows )
And while I now do understand that it’s not working, the docs are confusing, especially when you just start giving an example that it can work from the content folder isn’t helping.
Whatever „it“ is here. There’s certainly no issue using images from page bundles in markdown files. A gazillion of people do it every day. It fits just not work the way you thought it would. @irkode gave you some examples how to make „it“ work.
Take your time learning. Hugo is a complex piece of software. And you should not assume that it contains trivial bugs like the one you assumed to have discovered. Other people would’ve found that one long ago.