Blog Post site search returns the html title instead of the post name

Hi there,
I am building a blog post site search and the results returns the post html title insdead of the name of the post.
I have looked into the results object and it doesn’t seem to be pulling the name at all.
How can I make it pull the name of the post as well?

Hey, @RobertPupaza :waving_hand: Can you share an example of the request and response, please? Without more information, it’s challenging for our community members to understand what the root issue might be or what troubleshooting steps to suggest.

Best,

Jaycee

Hello @Jaycee_Lewis! I’m hoping I can resurrect this discussion since I’m currently trying to troubleshoot the same exact issue.

I’m currently building a blog listings page for my website (using the Hubspot Design Manager). One piece of functionality I’m trying to accomplish is a search results page using Hubspot’s search_results.module as an example.

I’m getting a valid response based on my search terms, but, as @RobertPupaza noted above, the results include the HTML meta title, but not the blog post title (which I would really prefer to use for my results display)

Here’s my request:

const getSearchResults = (limit) => {
 const urlParams = new URLSearchParams();
 urlParams.append("q", searchTerm);
 urlParams.append("limit", limit);
 urlParams.append("type", "BLOG_POST");
 urlParams.append("autocomplete", "true");
 urlParams.append("analytics", "true");

 return new Promise((resolve, reject) => { 
 const requestUrl = `/_hcms/v3/site-search/search?${urlParams.toString()} `;
 const request = new XMLHttpRequest();
 request.open("GET", requestUrl, true);
 request.onload = function () {
 if (request.status >= 200 && request.status < 400) {
 try {
 const data = JSON.parse(request.responseText);
 console.log(data)
 if (data.total > 0) {
 resolve(data); // Resolve with the data
 } else {
 resolve(null); // Resolve with null for no results
 }
 } catch (error) {
 reject(error); // Reject on JSON parsing errors
 }
 } else {
 reject(new Error("Server error: " + request.status)); // Reject on HTTP errors
 }
 };

 request.onerror = function () {
 reject(new Error("Network error")); // Reject on network errors
 };
 request.send();
 });
};

And here’s an example of a response:

{
 "id": 173383912294,
 "score": 39.123085,
 "type": "BLOG_POST",
 "domain": "my-domain",
 "url": "http://my-domain/blog-post",
 "featuredImageUrl": "https://46465493.fs1.hubspotusercontent-na1.net/hubfs/46465493/blog-post.png",
 "language": "en",
 "title": "<span class=\"hs-search-highlight hs-highlight-title\">Holiday</span> Blog Post",
 "description": "Here's a description of my blog post. It has a lot of information about the topic I am writing about.",
 "authorFullName": "authorFullName",
 "tags": [],
 "publishedDate": 1664769600000,
 "isPrivate": false
}

It has almost everything I need, except for that blog title. I’ve tried a lot of different configurations and settings, but have had no luck so far. Any advice? Thanks!
Mark

Hi, @MarkMcKenna5 :waving_hand: Let’s ask some of our community experts to lend a hand, hey @alyssamwilie @EddBrisley @KenF do you have any thoughts on how @MarkMcKenna5 can accomplish their goal?

Thank you! — Jaycee

@MarkMcKenna5 @Jaycee_Lewis

The site search API v3 documentation does show two separate fields name and title. It looks like you’re using the v3 API, are you still not seeing the name field in the response?

"fields": {
 ...
 "name_nested.en": {
 "name": "name_nested.en",
 "values": [
 "Inbound Marketing Vs. Outbound Marketing"
 ],
 "value": "Inbound Marketing Vs. Outbound Marketing",
 "metadataField": false
 },
 "title_nested.en": {
 "name": "title_nested.en",
 "values": [
 "Inbound Marketing Vs. Outbound Marketing"
 ],
 "value": "Inbound Marketing Vs. Outbound Marketing",
 "metadataField": false
 },
 ...
}

If you’re calling it correctly and still not seeing the name field then that might be some discrepency or issue with the v3 API. I have seen it mentioned that the API can sometimes return different data depending on the context.