I have a dynamic page for faculty members on a client website. I'm looking for a way to change the page title (<title></title> on the html head section) to match the faculty member's name instead of the parent page.
Let's assume we have the following structure: - Faculty Listing Page (the page title) - Faculty Member (the page title remains "Faculty Listing Page")
Dynamically created pages already use {{ page_meta.html_title }} to pull in a table column so it doesn't need to be changed. When a table is set to be dynamic a Page Title column is automatically added to the table and one only needs edit those columns to the title they want.
If this answer solved your question, please mark it as the solution.
OK - I had to go back to the documentation page (https://developers.hubspot.com/docs/cms/guides/dynamic-pages/hubdb)to make sure that I wasn't completely missing the support mechanics here, although they do seem to skip a step or two. I tend to use somewhat different ways to exploit HubDB data, but this looks like a fairly standard path.
I'ts clear you have 90% of this working already, so hopefully this helps complete things for you.
Assuming you CMS template structure is pretty conventional, you are looking already at base.html - which in my theme has the statements:
This is where the standard pages get the data entered into the page editor settings dialogs into title and description into the actual page HTML.
It seems you have two options to customize the metadata:
- Set up the content required explicitly in each row of your HubDB table in the extra hs_name column that's added when you configure the HubDB table for dynamic page generation.
- Use a macro variable reference {{ dynamic_page_hubdb_row.name }} to get hold of the contents of the name column of your table (or whatever hold teh right data) and format the title string in the manner you would like - for example:
<title> "Faculty member {{ dynamic_page_hubdb_row.name }}" </title>
And similarly set up the custom meta description.
I might do this in a clone of the base.html and use that clone reference in your actual page template file. But it also seems that you may be able to detect the use of dynamic pages on the fly using:
{% if dynamic_page_hubdb_row %}
and adapt the generic base.html code to deal with standard and dynamic cases.
Dynamically created pages already use {{ page_meta.html_title }} to pull in a table column so it doesn't need to be changed. When a table is set to be dynamic a Page Title column is automatically added to the table and one only needs edit those columns to the title they want.
If this answer solved your question, please mark it as the solution.
@FSena - are these pages that are dynamically generated (ie. via HubDB or other structured data)?
I ask because, in general you would want to set the page title string using a dynamically generated page value, referenced by {{ name of individual }} but its npt clear how you woudl set that variable.