I’ve been working on migrating a Hubl theme to the newer “React Project” framework using the migration docs and the react project quickstart. This is in reference to the include tag which pulls in a partial. Since our hubl theme is a fairly large project with many modules, I will demonstrate the bug using the theme created via the react project quickstart.
Create a hubl-modules folder, with a test.module folder inside that, and a meta.json and module.hubl.html inside that. Then add a partials folder inside templates with a partial-test.hubl.html file inside that.
- my-theme
-- hubl-modules
--- test.module
---- meta.json
---- module.hubl.html
-- templates
--- partials
---- partial-test.hubl.html
-- etc…
meta.json
{
“label”: “Test Module”,
“css_assets”: [],
“external_js”: [],
“global”: false,
“help_text”: “”,
“host_template_types”: [
“PAGE”
],
“js_assets”: [],
“other_assets”: [],
“smart_type”: “NOT_SMART”,
“tags”: [],
“is_available_for_new_content”: true
}
module.hubl.html
<p>This is a test module.</p>
{% include ‘@projects/my-cms-theme/theme/my-theme/templates/partials/partial-test.hubl.html’ %}
partial-test.hubl.html
<p>This is from the partial!</p>
This will build, but when you add the module to a page and view the source, it displays:
<!-- Missing Template at Path: ‘@projects/my-cms-theme/theme/my-theme/templates/partials/partial-test.hubl.html’ -->
This is despite the template existing in the project UI:
Note that using any other path in the include tag, including relative paths (../../templates/partials/etc…) ,absolute paths, and other variations of @projects/etc… will result in build errors:
File at path ‘x’ does not exist
This appears to be the only path that DOESN’T result in a build error, and therefore must be the correct path to the file.
I have spent multiple days now trying to figure out how to simply use partials in the way described in the documentation in a Hubl Theme migrated to a React Project. Is this simply a bug? Was the functionality to include partials in modules removed, and if so, where is that documented? Or, what am I doing wrong?
On a side note, I’ve had to spend MULTIPLE HOURS typing this post into here because these forums appear to reformat your post automatically and break any code formatting that may have been entered. For that reason, unfortunately, the code formatting in this post will be jank. It’s quite the cherry-on-top to get even more frustrated with HubSpot just trying to post a question in the forums.
