.isHome is false on homepage for footer only

I’m trying to add a CSS and JS plugin on my homepage. All other pages do not need the plugin so I don’t want the code to be loaded there. I want to load the CSS in the header and the JS in the footer and I am using .isHome to check for the homepage. While the script in the header.html loads, the one in footer.html doesn’t load as .isHome in the footer seems to be false. The issue looks very similar to this one, but I am not using partialCached.

The index.html for the homepage looks like this:

{{ partial "header.html" . }}
{{ partial "banner.html" . }}
{{ partial "footer.html" }}

so there is no partialCached, neither is in any other layout templates. I’m always using partial to load templates.

the line in header.html looks as follows:

{{ if .IsHome }}<link rel="stylesheet" href="{{ "plugins/xyz/xyz.min.css" | absURL }}">{{ end }}

the line in footer.html looks as follows:

{{ if .IsHome }}<script src="{{ "plugins/xyz/xyz.min.js" | absURL }}"></script>{{ end }}

Now, when loading the page, the line in the header gets loaded and I can see it in the source, however in the footer section, there is an empty line where the script line should appear. I’ve done the following test:

{{ if .IsHome }}<script src="{{ "plugins/xyz/xyz.min.js" | absURL }}"></script>{{ else }}test{{ end }}

and with that test, the word test appears in the footer, so parsing generally seems to work, however for some reason .isHome seems to be false for the footer, while for the header it’s true.

I do not use any theme overrides outside the theme in layouts (the folder is empty) and as mentioned I do not use partialCached.

Hugo Static Site Generator v0.56.1/extended darwin/amd64 BuildDate: unknown

Any ideas how to fix this?

you missed the dot!
{{ partial "footer.html" . }}


Wow, so obvious, but I couldn’t see it. Thank you so much.

we all must make this error to learn from it :upside_down_face: