If this is about how to match for your Javascript files, you need to show how your content is structured. What you posted should work if the following file structure is there:
And the layout does not know what is needed, but somehow needs to be informed.
Not working pseudo code:
<script {{ with .Params.module }} type="module" {{end}} {{ with .Params.defer}} defer {{end}} src="{{ .Permalink }}"></script>
Each section needs a different javascript resource (or none). /content/some/path/index.md/html is unsing the resource and knows how it needs to be rendered.
So the hopefully better question is. How do I define within my index.html how the resource needs to be rendered?
I’m aware of: Page Resources | Hugo But was not able to use the resources.params to store the information in the index.html and access it in: {{ range .Resources.Match “**.js”}}