Currently I have a website in which I have a many HTML documents that are included in a template as so:
{{ $file := printf "static/theories/%s.html" $site.File.TranslationBaseName}}
{{ if fileExists $file -}}
{{ readFile $file | safeHTML }}
{{- end }}
However as I use static files, these pages are rendered twice, once at the static link /theories/%s.html and once at the URL defined in the frontmatter. As ~100 of these HTML documents are large (1-22MB), site generation is slowed down by this page duplication.
The solutions here are either:
Being able to not publish static files
Data files which are not yaml, yml, json, or toml
(I’m not sure if I could make them assets, as they are not used in a Hugo Pipe?)
Unfortunately I don’t think put the HTML in the value of a JSON document as the HTML contains single and double quotes.
This is a niche edge case, but it would be useful to have it covered.
I’m not entirely sure I understand what you are asking though, and what your actual setup is. Do you mean you have HTML files under the /static/ folder, and you are including them via readFile?
It would be easier to help you if we could see your site code in a repo somewhere.
Wow I should’ve tested assets out before making this post — it works and my site generates in ~12% of the time it used to. I’ll update with the structure of my project and what’s going on.
Each theory in the content directory has it’s URL set to entries/%s/theories in the frontmatter so that the theories of any entry can be found at the standard subdirectory.
In layouts/theories/single.html I have the following: