Execute a template in 404.html

I have the following setup:

  • a module that has a file layouts/shortcodes/search.html
  • the module is mapped from layouts to layouts.
  • in my layouts/404.html I added {{ template "layouts/shortcodes/search.html" }}

I would expect this to work. But I end up with a not found error, not (yet) some error inside of search.html.

ERROR 2020/12/19 22:44:08 Render of "404" failed: execute of template failed: html/template:404.html:8:18: no such template "layouts/shortcodes/search.html"

Is this because 404.html is a specially rendered file? Or might it be that the template function can’t load from modules?

  • partials from the module are not found either - in 404.html. In other cases it works.

Move the shortcode to a partial and reference the partial in the shortcode. Templates can’t access shortcodes

neither partial nor template finds anything anywhere in the module.

The error is that it isn’t it can’t use layouts/shortcodes/search.html

Try move it to layouts/partials/search.html and replace layouts/shortcodes/search.html with {{< partial “search.html” >}}

That is not the error, because as I wrote twice, the 404 template does not load partials from the same module. It does ignore the module. And I am not going to put the layout files from the module into the local layouts directory.

I suspect the module is not set up properly.