Partials

Updated: September 28, 2024

Partials give more granular precision of when and where something is applied.


CSS PARTIAL

{{ if .Params.css }}
<link rel="stylesheet" href="{{ .Params.css }}">
{{ end }}

JS PARTIAL

{{ if .Params.js }}
<script src="{{ .Params.js }}"></script>
{{ end }}

For JS files included in the site itself, it would be best to include them in the assets/ dir instead of static/, as assets/ allows for automatic minification and fingerprinting, among other things.

I’ve spent some time trying to optimize the inclusion of assets on pages in my own theme, as part of a plugin structure I’ve implemented. If you’d like, some related files are linked below:

head.html 102 - loads CSS files in the of the website. foot.html 70 - loads JS files at the end of the of the website. styles 17 - partial that generates tags based on items in a dict. script 65 - partial that generates