How to get meta data from HubDB table

From a document request page, the visitor selects one item and the link passes the corresponding HubDB row id to the landing page, then to the fulfillment/thank-you page. I can’t figure out how to populate the page settings meta-description and title from the HubDB table row. Can this be done without building a dynamic table and template?

Thanks for your help!

Hey @wmflan39, thank you for posting in our Community!

A workaround is using JavaScript to fetch and update metadata on page load, but for full control, a dynamic page setup would be the best approach.

I want to invite our top experts, @Anton and @Josh do you have any other recommendations for @wmflan39 matter?

Thank you,

Pam

Hey @wmflan39,

if you don’t want to create a dynamic table, you’ll need to add the meta and title manually as columns to the table.
Once created, you should be able to can implement them like this

{% set row = hubdb_table_row(TABLE_ID, ROW_ID) %}
...
{% require_head %}
<title>{{ row.custom_title }}</title>
<meta name="description" content="{{ row.custom_meta }}">
{% end_require_head %}

This should add the data to the page - BUT - Important note: Will generate double tags. Which is something you don’t really want :slightly_smiling_face:

The only safe way is to create dynamic templates as HubSpot has some code running in the back that will recognize that it’s a dynamic template and replace the information - more or less - automatically once you’ve put the tags into the template.
I’d say it’s kinda like an if-statement

{% if dynamic_page and title and meta is provided %}
use dynamic title and meta
{% else %} {# for non dynamic pages #}
use title and meta from page settings
{% endif %}

^just an example of the logic.

Further info:
the default title and meta info is comming from the {{ standard_header_includes }} tag which is excluded from filters(just tested it), so the only other option would be - as @PamCotton suggested to create some sort of JavaScript with replace/infuse logic. But this should fire before the page builds as it may results in wrong tech. SEO results…

Can you please explain a bit further, why you don’t want to use dynamic table&templates?

best,

Anton

Many, many thanks @Anton and @anncotton for taking the time. This is very helpful. The reasons I wanted to avoid buiding a dymanic table and template were two-fold: 1) yikes! scary code! and 2) the article seemed to be describing either a catalog presentation or a blog listing/post presentation. My plan is to use the data one page at a time,on-demand, from our listing of >500 application notes. Ok, ok I’ll start working on the template page.

Thanks again, William