Jun 29, 20218:59 AM - edited Jun 29, 20219:35 AM
Key Advisor
Exclude domain stylesheet in html template
SOLVE
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.
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)
Matthew Scott Head of Development | Hubspot Solutions Architect
B2B marketing agency: Specialist B2B content marketing and demand generation for SaaS vendors and HubSpot Users | Deeply Digital | HubSpot Partner since 2010
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)
Matthew Scott Head of Development | Hubspot Solutions Architect
B2B marketing agency: Specialist B2B content marketing and demand generation for SaaS vendors and HubSpot Users | Deeply Digital | HubSpot Partner since 2010
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
Matthew Scott Head of Development | Hubspot Solutions Architect
B2B marketing agency: Specialist B2B content marketing and demand generation for SaaS vendors and HubSpot Users | Deeply Digital | HubSpot Partner since 2010
Jun 29, 20218:59 AM - edited Jun 29, 20219:35 AM
Key Advisor
Exclude domain stylesheet in html template
SOLVE
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.
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)