CMS Development

pger
Participant

Dynamic file links in HubSot CMS files

SOLVE

Hello everyone

 

I have a question about linking single files: I found the following function "get_asset_url" in the help of HubSpot (https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#get-asset-url).

 

Do I have understood correctly that this function only works for .js, .html and .css files (so I can link these types of files within each other)?

 

But is there a possibility to link dynamically to other elements (e.g. SVG graphics) within .js and .css files?

 

The background of my question is that I am currently building a new website in a test portal and want to transfer it to our account afterwards. With this dynamic URL I would have one less source of error if I don't have to replace all URLs later.

Thanks for the support.


Best
Pascal

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Dynamic file links in HubSot CMS files

SOLVE

Hi, @pger.

 

Apologies for the delayed response. I'm happy to clarify.

 

Yes, the get_asset_url HubL function only works for HTML/HubL, CSS, and JS files.

 

No, you wouldn't be able to link other types of files with this function since it only works with assets uploaded to the Design Manager where only HTML/HubL, CSS, and JS files can reside.

If you uploaded the SVG files to your file manager, however, you could reference the file with the file_by_id function. See the sample here.

Isaac Takushi

Associate Certification Manager

View solution in original post

2 Replies 2
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Dynamic file links in HubSot CMS files

SOLVE

Hi, @pger.

 

Apologies for the delayed response. I'm happy to clarify.

 

Yes, the get_asset_url HubL function only works for HTML/HubL, CSS, and JS files.

 

No, you wouldn't be able to link other types of files with this function since it only works with assets uploaded to the Design Manager where only HTML/HubL, CSS, and JS files can reside.

If you uploaded the SVG files to your file manager, however, you could reference the file with the file_by_id function. See the sample here.

Isaac Takushi

Associate Certification Manager
pger
Participant

Dynamic file links in HubSot CMS files

SOLVE

Hi Isaac,

 

Thanks a lot for your clarifications. file_by_id is a good function but since I have a lot more than 10 files in my css it won't work in my case.

 

Best,

pascal

0 Upvotes