How do I write custom Javascript or CSS files for my pages?

Last updated: October 20, 2017

Available For:

Marketing: Basic, Pro, Enterprise
Sales: N/A
Service: N/A

To write a custom Javascript or CSS file in HubSpot, follow the steps below:

  • In your HubSpot Marketing account, navigate to Content > Design Manager.
  • Click New template > Code Editor > Create.
User-added image
  • Give the new file a name that includes the appropriate extension file type (.js for scripts / .css for css files/ .html for standard html files), select a location, then click Save.
User-added image
  • When you are done writing the coded file, click Actions > Get public URL to generate a HubL token that will be used to reference the file in your pages.
  • In the Public URL dialog box, click Copy, then click OK.
User-added image
  • To include your file on all HubSpot hosted pages, navigate to Content > Content Settings, then scroll down to the Site Footer HTML section and paste the generated HubL token as the value for the script tag’s source, as seen below:
<!-- start Main.js Do Not Remove -->
<script src='insert your generated token here'></script>
<!---End Main.js-->
  • Scroll down and click Save changes to finish.

Was this article helpful?