Bundle JS script

I want to have calculators in static pages;
For calculator pages I use custom layout html pages that has javascript files (calculator.js)

  • Where do I place the calculator.js file in project?
  • How do I get it to go to the correct folder for reference in the public build?


title = 'Post 1'
layout = 'calculator'

There's a calculator thingy on this page.

layouts directory

└── _default/
    ├── baseof.html
    ├── calculator.html  <-- this corresponds to the layout field in front matter
    ├── home.html
    ├── list.html
    └── single.html

assets directory

└── js/
    └── calculator.js


{{ if eq .Layout "calculator" }}
  {{ with resources.Get "js/calculator.js" }}
    <script src="{{ .RelPermalink }}"></script>
  {{ end }}
{{ end }}