CMS Development

FSena
Member

Dynamic Page Title tag

Hey all,

 

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")

 

Is there a way to code this on my base.html file?

0 Upvotes
4 Replies 4
SteveHTM
Top Contributor | Partner
Top Contributor | Partner

Dynamic Page Title tag

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:

<title>{{ page_meta.html_title }}</title>
<meta name="description" content="{{ page_meta.meta_description }}">

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.

 

Hope I'm on the right track here.

 

Steve

 

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
alyssamwilie
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Dynamic Page Title tag

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.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
0 Upvotes
SteveHTM
Top Contributor | Partner
Top Contributor | Partner

Dynamic Page Title tag

@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.

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
FSena
Member

Dynamic Page Title tag

That's excatly right, sorry for the delayed response. It is data retrieved from a hubdb that I'm talking about.

 

Since this is data retrieved from a hubdb, is there any chance to get a dynamic page title as well? 

0 Upvotes