CMS Development

ParkerShort
Contributor | Diamond Partner
Contributor | Diamond Partner

Expanding on a directory with HubDB

Hey everyone,

HubDB was definitely something that caught my eye coming out of Inbound 16. I saw that one use case given was a team page (https://designers.hubspot.com/docs/tutorials/lets-build-a-team-page-with-hubdb). 

 

I have this exact need and would love to try out HubDB to accomplish it. However, I need to have separate pages for each team member as well. We like to track visits and leads separately this way. Is there a way to use HubDB to power not just a directory, but the individual pages as well? It looks like I can set up custom modules that call the specific row ID for each team member, but that's not much less work than just doing it manually. 

 

Alternately, is there a way to import one row into a custom module for the drop-down selection? It'd be great to just have to select someone's name and then have the page template pull in all the other information. Interested to hear what some options are. Thanks!

 

Parker

0 Upvotes
5 Replies 5
boulter
HubSpot Product Team
HubSpot Product Team

Expanding on a directory with HubDB

Hi Parker, you can definitely do this with HubDB. It would go something like this.

{% set member_id = request.query_dict['member_id'] %}
{% if member_id %}
    {% set params = "member_id=" ~ member_id %}
    {% set row = hubdb_table_rows(YOUR_TABLE_ID, params) %}
    <p>{{ row.first_name }} {{ row.last_name }}</p>
{% else %}
    {% for row in hubdb_table_rows(YOUR_TABLE_ID) %}
       <p><a href="?member_id={{row.member_id}}">{{ row.first_name }} {{ row.last_name }}</a></p>
    {% endfor %}
{% endif %}

Assuming you have a table with columns member_id, first_name and last_name, this will show all team members if no query string is passed. If they click the link for a team member, it will reload the page with a member_id parameter which will then execute the first block of code that will get only a single team member.

cmathieu
Participant | Elite Partner
Participant | Elite Partner

Expanding on a directory with HubDB

First of all this is awesome and I'm psyched to see HubSpot moving more towards more data-driven content on COS websites. I've been a long-time fan of repurposing the blog for dynamic content but I could see reasons why it would be more efficient to use HubDB.

 

My main question on it all was exactly what Parker asked. Can you have a unique detail page that gets linked from the listing page? It seems that the answer is yes but I'm wary of using this method on production sites for the following SEO/UX reasons:

 

1. We wouldn't be able to have a good unique slug for the detail page. We'd have something like /?id=23423 which isn't good for SEO

2. We could run into canonical page issues

3. We wouldn't have unique meta title, description, etc which is HUGE for SEO and social sharing

4. It would be nice to be able to use a different page template for detail vs listing

 

Again I think this is awesome and commend HubSpot for adding it but wonder if the above issues/questions are already on the roadmap. I'm definitely going to be playing with this a lot internally but for production sites that need a detail page with data driven content I'm going to stick to repurposing the blog for now.

 

Let me know what you think.

 

Thanks!

-Chris

 

boulter
HubSpot Product Team
HubSpot Product Team

Expanding on a directory with HubDB

Hi Chris,

I see your points and providing a way to have separate detail and listing pages is something we're planning. You could use an hash param instead of query param, but that's probably not much better for SEO.

 

On #4, you can certainly create another template and page for details and link from listings to that other page. They don't have to be the same page/template as the listings. Of course, the path would be the same for each item with the only the query string parameter id of the detail page being different.

ParkerShort
Contributor | Diamond Partner
Contributor | Diamond Partner

Expanding on a directory with HubDB

Hey Boulter,

Thanks for the explanation. Like Chris, I really need true separate pages, both for SEO purposes, and being able to track visits and clicks differently (I'm assuming the hash solution would still have all the traffic tracked to one page.). I have a use case for an existing client if that helps you out when working on this. Let me know if you want to discuss.

 

Parker

0 Upvotes
cmathieu
Participant | Elite Partner
Participant | Elite Partner

Expanding on a directory with HubDB

Thanks for clarifying point #4 very helpful. And glad to hear the formal detail page is on the roadmap. 

 

-Chris

0 Upvotes