# How does the {{ standard\_header\_includes }} function render default and custom module CSS?

**URL:** <https://community.hubspot.com/t/how-does-the-standard-header-includes-function-render-default-and-custom-module-css/84388>\
**Category:** CMS Development\
**Tags:** enterprise\
**Created:** [June 29, 2023, 2:29pm UTC](https://community.hubspot.com/t/how-does-the-standard-header-includes-function-render-default-and-custom-module-css/84388 "2023-06-29T14:29:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PPope](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@PPope](https://community.hubspot.com/u/PPope)\
**Post date:** [June 29, 2023, 2:29pm UTC](https://community.hubspot.com/t/how-does-the-standard-header-includes-function-render-default-and-custom-module-css/84388/1 "2023-06-29T14:29:41Z")

</div>

----  
The site I am currently working on is very custom and did not start from any HubSpot core files.  
And instead of using the {{ standard\_header\_includes }} function the original developer used a custom block function to bring in specific files from the site settings and css files:

{% block standard\_header\_includes\_ %}  
custom code  
{% endblock %}  
Now, the issue is the {{ standard\_header\_includes }} function is what makes it possible for HS to render custom & default modules CSS.  
I could just include both the {{ standard\_header\_includes }} func, current block func but that is too duplicative, and messes up a lot of CSS.  
I could also just remove the block function, but again, messes up too much CSS.  
Ideally, I would like to figure out what specifically about the {{ standard\_header\_function }} it is that makes it possible for HS to render module css and then incorporate that into the block function.  
--------  
Video Demo: [https://www.dropbox.com/s/d0gu3a7xh6ld2v5/SHI\_funct.mp4?dl=0](https://www.dropbox.com/s/d0gu3a7xh6ld2v5/SHI_funct.mp4?dl=0)  
Current block Function code  
{% block standard\_header\_includes\_ %}  
{{ standard\_header\_includes|regex\_replace(  
(site\_settings.head\_html ? userCodeToRegex(site\_settings.head\_html) ~ “|” : “”) ~  
(content.head\_html ? userCodeToRegex(content.head\_html) ~ “|” : “”) ~  
“{{ head\_elements\\(\\) }}” ~ “|” ~  
“{{ head\_css\\(\\) }}” ~ “|” ~  
“\<meta name=\“viewport\”.\*\>” ~ “|” ~  
"\<meta property=\“og:.\*\>” ~ “|” ~  
"\<meta name=\“twitter:.\*\>” ~ “|” ~  
“\<meta http-equiv=\“content-language\”.\*\>” ~ “|” ~  
“{{ include\_default\_custom\_css\\(content.include\_default\_custom\_css, template\_meta.include\_default\_custom\_css, domain\_settings.include\_default\_custom\_css\\) }}” ~ “|” ~  
“{{ include\_attached\_css\\(content\_group.attached\_stylesheets or domain\_settings.attached\_stylesheets, content.enable\_domain\_stylesheets, template\_meta.enable\_domain\_stylesheets, theme\_meta.enable\_domain\_stylesheets, domain\_settings.enable\_domain\_stylesheets\\) }}” ~ “|” ~  
“{{ include\_attached\_css\\(template\_meta.attached\_stylesheets, content.enable\_layout\_stylesheets\\) }}” ~ “|” ~  
“{{ include\_attached\_css\\(content.attached\_stylesheets\\) }}” ~ “|” ~  
“{{ require\_attached\_js\\(template\_meta.attached\_js\\) }}”,  
“”)  
}}  
{% endblock %}

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [June 29, 2023, 4:17pm UTC](https://community.hubspot.com/t/how-does-the-standard-header-includes-function-render-default-and-custom-module-css/84388/2 "2023-06-29T16:17:51Z")

</div>

Hi @PPope,

thanks for the video! Helps a lot!

The [{{ standard\_header\_includes }} functions](https://developers.hubspot.com/docs/cms/hubl/variables#required-page-template-variables) is a code snippet that is handled by HubSpot on the backend side which nobody except HubSpot technicians can access. If you’re using code elements like

```lia-code-sample
{% require_css %}
<style>
some css styling
</style>
{% end_require_css %}

```

or

```lia-code-sample
{% require_head %}
something that should be rendered in the <head>-tag
{% end_require_head %}

```

in templates, modules etc. it will be appended to the {{ standard\_header\_include }} function automatically.

Also the approach of including the CSS files is something I’ve never seen before to be honest.

It’s extremly unflexible to the default/best-practise useage of CSS.

Normally you go with a “SCSS” approach like creating a bunch of small CSS files for all kind of default styling(forms, typography, buttons, grid…) include them in a “main.css”(name doesn’t matter) file and then you have several options

1. create a big “theme-overwrite.css” file which contains only overwrites from the theme settings(fields.json of a theme) and is getting loaded after the main.css file so it overwrites some styles
2. create a bunch of single use CSS files per module and connect them inside the module. Either in the meta.json of a module or via the design-tools. If you link those files in the module those files are getting appended automatically in the {{ standard\_header\_include }} function. The good thing with this approach is: only the css files that are required by the used modules on this specific page are getting loaded once (even if you have several module instances on one page). Those single CSS file can also include the theme settings.

Many, many ways how you can optimize/load your CSS files. Almost the same goes for the JS files. Either you creat one big file (might have an impact on page speed) or a bunch of smaller ones for specific modules.

Of course every developer/theme provider has it’s own coding approach but a good start is always the [boilerplate](https://developers.hubspot.com/docs/cms/building-blocks/themes/hubspot-cms-boilerplate). In your specific case I’d recommend to take a look at the folder structure and how the files are connected.

hope that helps,

best,

Anton

---

<div class="post-metadata">

**Author:** ![PPope](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@PPope](https://community.hubspot.com/u/PPope)\
**Post date:** [June 29, 2023, 4:37pm UTC](https://community.hubspot.com/t/how-does-the-standard-header-includes-function-render-default-and-custom-module-css/84388/3 "2023-06-29T16:37:37Z")

</div>

Thanks Anton,  
I’m leaning towards deconstructing the function block function and adding those files into the main.css file…which is sounds like what option 2 is getting at.  
This site overall is very challenging to edit as the original developer did not start with any sort of HS boilerplate files. Which I have never seen before with any theme, be-it free or premium.  
Basically, the orginal developer tucked EVERYTHING into the base.html—pretty much all the files that would typically be housed in the CSS folder [Components, Elements, Generic, Objects, Templates, Tools, Utitlity] files were written out in the base.html file…it’s pretty wild.  
In my Sandbox I did merge in the HS Boilerplate files, which does help. Though it still is not solving the main issue of not being able to render module css. Which requires the {{ standard\_header\_includes }} func.  
Anyways, I’m going to try to deconstruct that block function now in Sandbox and see if it works.  
Thanks, I will let you know if it work.

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [June 29, 2023, 4:49pm UTC](https://community.hubspot.com/t/how-does-the-standard-header-includes-function-render-default-and-custom-module-css/84388/4 "2023-06-29T16:49:11Z")

</div>

sorry to hear that. Might be wrong - but this sounds like A LOT of work.

Maybe starting all over “on a blank canvas” in a sandbox account could be an idea so you know how everything is connected. After you’re done you can move it from dev to production environment

Let me know if you have further questions or need some help

best

---

<div class="post-metadata">

**Author:** ![PPope](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@PPope](https://community.hubspot.com/u/PPope)\
**Post date:** [June 29, 2023, 4:53pm UTC](https://community.hubspot.com/t/how-does-the-standard-header-includes-function-render-default-and-custom-module-css/84388/5 "2023-06-29T16:53:23Z")

</div>

Shouldn’t be too much…I’ve become really fimilar with how the site was built and it’s managble now.  
The last main hurdle is to make module css to render via {{ SHI }}.  
I’ll let you know how it goes.
