Trying to fix warnings caused by include/import inside global_partial
Recently I started to use the ?hsDebug=true query parameter to dive into some weird loadings I was seeing with our theme. I believe it is all fixed now, except some warnings I have been unable to fix. They do not seem to affect our pages, but they make it a lot harder to spot new warnings being introduced.
The general structure of our theme follows the often cited cms-theme-boilerplate: templates includes a folder layouts with a base.html that uses 2 {% global_partial %} tags to pull in separate header and footer files:
These partials make use of {% include %} and {% import %}. Example:
<!--
templateType: global_partial
label: Site Header
-->
{% include '../../languages/lang.html' %}
{% import '../../components/all.html' as component %}
{% import '../../inc/all.html' as sleek %}
This results in a bunch of warnings like:
TemplateError{severity=WARNING, reason=MISSING, item=TEMPLATE, message='Warning in `refapp-theme/templates/global-partials/site-header.html` on line 3: Resolving path ../../languages/lang.html from parent template, use relative path from module instead', fieldName='path', lineno=2, startPosition=1, scopeDepth=3, category=MODULE_PATH_FALLBACK, categoryErrors={path=../../languages/lang.html}}
This confuses me and I have been unable to get rid of these warnings. What is a parent template here? There is just the one base.html. Why talk of modules when we are inside a template? And why tell me to use a relative path when the path is already relative?
It is doubly confusing because it does work. The files are included/imported, as variables and macros respectively are made available and the site renders correctly.
Anyone here in the community have any ideas for fixing these warnings?
Trying to fix warnings caused by include/import inside global_partial
Hi, @tw-martijn👋 Thanks for reaching out. Let's see if we can get the conversation going — hey @Gonzalo@Sjardo@tjoyce, do you have any suggestions or troubleshooting tips for @tw-martijn?