# Blog Post Issue - Similar Posts

**URL:** <https://community.hubspot.com/t/blog-post-issue-similar-posts/106478>\
**Category:** CMS Development\
**Tags:** enterprise\
**Created:** [May 4, 2024, 8:33pm UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478 "2024-05-04T20:33:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JDoxy07](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@JDoxy07](https://community.hubspot.com/u/JDoxy07)\
**Post date:** [May 4, 2024, 8:33pm UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478/1 "2024-05-04T20:33:01Z")

</div>

Hello 🙂  
I think ave found a critical bug in HubSpot that I cannot find a solution for.

After reading all the HubSpot documentation and comparing it with other projects and HubSpots I manage, I’ve concluded that this is an issue on HubSpot’s part that I can’t fix it 😞 I think.  
I’ll try to explain.  
I have a blog with different articles, and each blog post has only one associated tag (not multiple). At the end of each article, there is a “Similar posts” section. However, when I use the code to fetch similar posts and print the tag variable I am passing as a parameter, it does not return the correct results.  
For example, if I open a post with the tag “Recruitment,” it works fine, but with the tag “sales,” it does not work.  
And if you check my code screenshots, you can see that everything is correct and the variable containing the tag is printing correctly. So, I don’t understand how a post with the tag “sales” is showing related posts that are not about sales.

 ![image_2024_05_04T16_38_53_745Z.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/c/3c3916282bfb6a58e9aed6a5c105f815b73df0ec.png)  
Sales Tag  
 ![image_2024_05_04T16_38_07_843Z.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/b/9bea1bc44fca622307553386d8b21d8822988c0f.png)  
Recruitment Tag  
 ![image (2).png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/7c2fe4bdca32186dade047040ab989415dd94b7f.png)

 ![image (1).jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/d/6d7c90e87591a8604d0d435fef3cb0396aebc7d5.jpeg)  
Sales Tag post  
 ![image.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/7/67c48d0dcfa5cf26c7b638ae87c6ad9cb59c3755.jpeg)  
Recruitment Tag Post

---

<div class="post-metadata">

**Author:** ![jnix284](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jnix284/32/29_2.png) [@jnix284](https://community.hubspot.com/u/jnix284)\
**Post date:** [May 5, 2024, 1:37am UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478/2 "2024-05-05T01:37:48Z")

</div>

@JDoxy07 this is interesting, thank you for sharing so much detail and screenshots to explain the issue.

Non-code question - on the blog, are there enough posts tagged “sales” to fill the 6 related post spots (at least 6)? or are there only the 3 shown?

Is the desired behavior that you only want the 3 sales posts to show, if there aren’t more?

---

<div class="post-metadata">

**Author:** ![JDoxy07](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@JDoxy07](https://community.hubspot.com/u/JDoxy07)\
**Post date:** [May 5, 2024, 3:27pm UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478/3 "2024-05-05T15:27:04Z")

</div>

Hello @Jnix284 thank you for your message.  
I was expecting someone to raise that question. 😄

But it’s all right because, for instance, I have 8 articles in total with the tag ‘Sales’ and 10 with the tag ‘Recruitment.’

So, as I have a limit of 6, everything should be displaying correctly. 😞

---

<div class="post-metadata">

**Author:** ![jnix284](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jnix284/32/29_2.png) [@jnix284](https://community.hubspot.com/u/jnix284)\
**Post date:** [May 7, 2024, 1:19am UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478/4 "2024-05-07T01:19:40Z")

</div>

Thanks for the additional details @JDoxy07, thats what I suspected, I just wanted to be sure.

Without being able to dig into the code and try to recreate the issue, I’m not sure how else I can help - it looks like you have identifying info blurred and can’t share the code or link directly.

Perhaps @Anton can spot something in the code that you and I have missed.

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [May 7, 2024, 11:09am UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478/5 "2024-05-07T11:09:40Z")

</div>

Thanks for thinking of me @Jnix284 😁

Hi @JDoxy07,

without seeing the code as a whole it’s quite hard to tell what might be off but the one thing that seems to be a bit off is the

```lia-code-sample
{% if featured_tag %}
...
{% else %}
...
{% endif %}

```

statement.

The only thing it does is checking if there’s **any** tag available. Unless you’re checking for “if featured\_tag equals post\_tags” somewhere in your code/macro it will only do the following:

“If tag is available show posts with the tag - else - show other posts”

And this is what your code does. So I’d assume that there’s no logic that matches the featured\_tag to post\_tags.

Have you tried something like this:

```lia-code-sample
{% if featured_tag == post_tags[0] %}
...
if the post_tag matches
{% else %}
...
if the post_tag doesn't match
{% endif %}

```

best,

Anton

_Moderator note: While this solution may not address the original poster’s specific situation, it could be helpful for other community members facing similar challenges._

---

<div class="post-metadata">

**Author:** ![JDoxy07](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@JDoxy07](https://community.hubspot.com/u/JDoxy07)\
**Post date:** [May 7, 2024, 11:26am UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478/6 "2024-05-07T11:26:03Z")

</div>

Hello @Anton thank you for your message.

I understand your message

However, the **feature\_tag** and the **post\_tag** are exactly the same.

I included both approaches so you could see and verify through **data-feature-tags** and **data-posts-tags** what the variables were outputting at that moment.

And as you can see, they are printing correctly.

They always enter the **first if** statement.

So, it should have been done correctly.

Remember that removing the if statements and leaving just this instruction:

`{% related_blog_posts limit=6, no_wrapper=True, post_formatter="recent_post", tags="Sales"%}`

Directly placing, for example, the tag “sales” still lists some posts that are not “sales” as shown in the images.

Do you understand the problem now?

thanks

---

<div class="post-metadata">

**Author:** ![JDoxy07](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@JDoxy07](https://community.hubspot.com/u/JDoxy07)\
**Post date:** [May 7, 2024, 11:17am UTC](https://community.hubspot.com/t/blog-post-issue-similar-posts/106478/7 "2024-05-07T11:17:41Z")

</div>

Hello @Jnix284 thanks a lot for you help.  
The information that is blurred is just the blog post title. It’s only important to check that the tags on the images are correct.  
And in the code, I simply applied a blur to the name of a class. 🙂
