Jun 27, 2021 5:22 PM
Is there a tag/function/filter that can exclude the domain stylesheet in an HTML template?
Solved! Go to Solution.
Jun 29, 2021 8:59 AM - edited Jun 29, 2021 9:35 AM
I called support my self, they weren't able to help me with the Hubl, though I'm pretty sure there is a solution. They did help me track the stylesheet though and it wasn't where I assumed it was so I can remove it without effecting the whole domain now anyway.
Jul 23, 2021 5:28 AM - edited Aug 6, 2021 4:30 AM
Just found another solution, if you include the stylesheets in the header html section rather than the stylesheets section of the site settings, you can use hubl in the html section
with that hubl you can write an if statement to only render for a specific template or everything but a specific template e.g.
{% if !current_path is string_containing 'template-excludes-site-css.html' %}
<link stylesheets here>
{% endif %}
because your using the string_containing operator you can be specific to the full template path or part of the path (I just use my new theme path so every template will ignore those stylesheets) or even just a snippet you add to your template name e.g. templatename-nocss.html you could just match 'nocss'
edit: updated "is contains", to "is string_containing" as I'm not sure what the contains operator actually does (not in the docs)
Jan 7, 2022 4:10 PM
I would have thought this was what "enableDomainStylesheets: false" was for but that doesn't seem to work.
Jul 23, 2021 5:28 AM - edited Aug 6, 2021 4:30 AM
Just found another solution, if you include the stylesheets in the header html section rather than the stylesheets section of the site settings, you can use hubl in the html section
with that hubl you can write an if statement to only render for a specific template or everything but a specific template e.g.
{% if !current_path is string_containing 'template-excludes-site-css.html' %}
<link stylesheets here>
{% endif %}
because your using the string_containing operator you can be specific to the full template path or part of the path (I just use my new theme path so every template will ignore those stylesheets) or even just a snippet you add to your template name e.g. templatename-nocss.html you could just match 'nocss'
edit: updated "is contains", to "is string_containing" as I'm not sure what the contains operator actually does (not in the docs)
Aug 3, 2021 1:57 PM
@matt_scott nice one. this is a cool trick 👍
Jul 16, 2021 5:18 AM
I wouldn't call that a solution, I'm looking for the same function, I cloned a template to html but the template has the exlude domain stylesheets, this doesn't seem to be an option in HTML stylesheets. and for me the CSS is used in 67 live pages across the domain so removing it is not an option. best I can think is to just do a replace on the {{ required_head_tags }} tag but probably not the nicest solution
Jun 29, 2021 8:59 AM - edited Jun 29, 2021 9:35 AM
I called support my self, they weren't able to help me with the Hubl, though I'm pretty sure there is a solution. They did help me track the stylesheet though and it wasn't where I assumed it was so I can remove it without effecting the whole domain now anyway.
Jun 28, 2021 5:47 AM
Hi @Jsum ,
Add your style css somthing like this:
{{ require_css(get_asset_url("../../css/main.css")) }}
Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.
Jun 28, 2021 2:25 AM
Hi @Jsum, the documentation explains how to remove it from selected pages: https://knowledge.hubspot.com/design-manager/create-edit-and-attach-css-files-to-style-your-site#att...
But if you need to do it in an HTML level, maybe the best would be to load your CSS directly into the code. By doing this, you could add an IF statement to load the style everywhere except in the pages you don't want to load it. You can do that by checking the URL for example (see: https://community.hubspot.com/t5/CMS-Development/Get-current-page-URL-slug/td-p/256422)