CMS Development

Jsum
Asesor destacado

Exclude domain stylesheet in html template

resolver

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

0 Me gusta
2 Soluciones aceptadas
Jsum
Solución
Asesor destacado

Exclude domain stylesheet in html template

resolver

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. 

Ver la solución en mensaje original publicado

0 Me gusta
matt_scott
Solución
Colaborador líder | Partner nivel Platinum
Colaborador líder | Partner nivel Platinum

Exclude domain stylesheet in html template

resolver

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

Ver la solución en mensaje original publicado

7 Respuestas 7
BGrennan
Colaborador

Exclude domain stylesheet in html template

resolver

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

0 Me gusta
matt_scott
Solución
Colaborador líder | Partner nivel Platinum
Colaborador líder | Partner nivel Platinum

Exclude domain stylesheet in html template

resolver

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
Asesor destacado

Exclude domain stylesheet in html template

resolver

@matt_scott nice one. this is a cool trick 👍

0 Me gusta
matt_scott
Colaborador líder | Partner nivel Platinum
Colaborador líder | Partner nivel Platinum

Exclude domain stylesheet in html template

resolver

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
Solución
Asesor destacado

Exclude domain stylesheet in html template

resolver

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 Me gusta
webdew
Guía | Partner nivel Diamond
Guía | Partner nivel Diamond

Exclude domain stylesheet in html template

resolver

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 Me gusta
albertsg
Guía

Exclude domain stylesheet in html template

resolver

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

You also connect with me on LinkedIn or Twitter