Is there a way to create dynamic metadata tags from an external json file into a template without using javascript? I the tag to be updated before page load.
For example:
<meta property=“og:title” content=“{{json.data.firstname}}'s page”/>
I think the only way to do this is with a server side function, or bring the JSON file into your website if you can; you could have it as a partial HTML file with the json (or at least an object array) set to a HubL variable, then import the partial wherever you need it e.g. below. A third option would be to push the JSON data to a HubDB and then pull the data for your page from there.
Partial file:
<!--
templateType: page
isAvailableForNewContent: false
-->
<!-- Begin partial -->
{% set objects = [{"firstname":"john", "lastname":"doe"},{"firstname":"jane", "lastname":"deer"}] %}
<!-- End partial -->
Usage:
{% include '/path_to_partial/json_partial.html' %}
{% for obj in objects %}
{{obj.firstname}}
{% endfor %}
No, I don’t think that’s possible as it’s mixing server side and client side. You can get local Hubspot assets/files with {{ get_asset_url() }}; and you can assign the result of HubL to a JS variable, but not the other way round (so you can’t, for example, fetch the JSON url and assign it to a HubL variable). If you want to use this JSON data as metadata, presumably it’s your own file so why can’t you simply upload it to Hubspot?