Assets missing protocol using get_asset_url

Hey Folks,

Hoping someone may be able to help guide me to a solution on an issue I am encountering with links to assets in my css files. So far this issue appears to be isolated to font files, but I am not sure why.

When I link the fonts via CSS using get_asset_url, the generated url is missing protocol (https) in the URL.

Hubspot CSS entry

url( {{ get_asset_url('../fonts/fa-solid-900.woff2') }} )

Hubspot Generated URL

url(//45725153.fs1.hubspotusercontent-na1.net/hubfs/45725153/raw_assets/public/arc-k_dev_theme/assets/fonts/fa-solid-900.woff2)

I have attempted to link the full path and relative path to the file. In both events, the protocol (https) is missing from the URL.

When I add the protocol (https) to the URL, the file is there.

https://45725153.fs1.hubspotusercontent-na1.net/hubfs/45725153/raw_assets/public/arc-k_dev_theme/assets/fonts/fa-solid-900.woff2

I really appreciate any help someone can provide!

Hi, @arcknowledge :waving_hand: Thanks for reaching out.

Let’s invite some community members into the conversation — hey @BarryGrennan @Anton @LucBenayoun, @SteveHTM can you share how you are handling this in your current workflow?

Thank you very much!

Diana

@arcknowledge - strangely - and I don’t know why this is the case - the HubL function seems ot be defined in such as way that it returns the path but not the protocol.

From the doc page:

I guess the use is supposed to be limited to the context of the page compilation system?

Hope this helps!

Steve

Yeah, there must be some reasoning behind it.
But you can get around it by using

{{ 'https:' + get_asset_url('../fonts/fa-solid-900.woff2') }}

and maybe to be totally safe

{{ 'https:' + get_asset_url('../fonts/fa-solid-900.woff2')|regex_replace('https?://', '') }}


Barry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn