CMS Development

Jsum
Key Advisor

Exclude domain stylesheet in html template

SOLVE

Is there a tag/function/filter that can exclude the domain stylesheet in an HTML template?

0 Upvotes
2 Accepted solutions
Jsum
Solution
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. 

View solution in original post

0 Upvotes
matt_scott
Solution
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Exclude domain stylesheet in html template

SOLVE

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


01926 334003

deeplydigital.co.uk

3 Morton Street, Leamington Spa, CV32 5SY, UK

View solution in original post

7 Replies 7
BGrennan
Contributor

Exclude domain stylesheet in html template

SOLVE

I would have thought this was what "enableDomainStylesheets: false" was for but that doesn't seem to work.

0 Upvotes
matt_scott
Solution
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Exclude domain stylesheet in html template

SOLVE

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


01926 334003

deeplydigital.co.uk

3 Morton Street, Leamington Spa, CV32 5SY, UK
Jsum
Key Advisor

Exclude domain stylesheet in html template

SOLVE

@matt_scott nice one. this is a cool trick 👍

0 Upvotes
matt_scott
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Exclude domain stylesheet in html template

SOLVE

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


01926 334003

deeplydigital.co.uk

3 Morton Street, Leamington Spa, CV32 5SY, UK
Jsum
Solution
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. 

0 Upvotes
webdew
Guide | Diamond Partner
Guide | Diamond Partner

Exclude domain stylesheet in html template

SOLVE

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.

0 Upvotes
albertsg
Guide

Exclude domain stylesheet in html template

SOLVE

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)



Did my answer help you? Mark it as a solution


Book time with me

You can also connect with me on LinkedIn