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?
content/posts/post-1.md
+++
title = 'Post 1'
layout = 'calculator'
+++
There's a calculator thingy on this page.
layouts directory
layouts/
└── _default/
├── baseof.html
├── calculator.html <-- this corresponds to the layout field in front matter
├── home.html
├── list.html
└── single.html
assets directory
assets/
└── js/
└── calculator.js
layouts/_default/baseof.html
{{ if eq .Layout "calculator" }}
{{ with resources.Get "js/calculator.js" }}
<script src="{{ .RelPermalink }}"></script>
{{ end }}
{{ end }}
1 Like