gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.73k stars 7.53k forks source link

templates.Exists ignores module layouts (inside module (inside module (...))) #8214

Closed davidsneighbour closed 2 years ago

davidsneighbour commented 3 years ago
$ hugo version
Hugo Static Site Generator v0.80.0-792EF0F4/extended linux/amd64 BuildDate: 2020-12-31T13:46:18Z

I have a "weird" module structure:

In the blocks module there is a layout loaded from modules.

{{ $partialPath := "footer/service-worker" }}
{{ partial $partialPath . }}

This works. The footer/service-worker.html is in the pwa module, the code above is in the blocks module, hugo runs from the samui-samui.de website root "module" site, ... thingy...

Now I wanted to somehow add a fallback for if the pwa module is not installed:

{{ $partialPath := "footer/service-worker" }}
{{ if templates.Exists ( printf "partials/%s" $partialPath ) }}
  {{ partial $partialPath . }}
{{ else }}
  {{ warnf "service worker module not properly installed" }}
{{ end }}

This results in WARN 2021/02/07 22:01:23 service worker module not properly installed instead of loading the partial that exists and is properly mounted.

Garuda is public for testing, if you need access to samui-samui.de let me know and I'll add you to the repo.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.