APIs & Integrations

CHugo
投稿者

Latest POSTS description not showing

解決

Hello,

I have a problem with the description in mi Latest posts, there are incorects , they are not showing the actual descriptions:

https://ai.reportlinker.com/resources

 

My code is this one:

<ul>
{% set rec_posts = blog_recent_posts("default", 3) %}
{% for rec_post in rec_posts %}
<li>
<div class="lp-block">
{% if rec_post.featured_image %}

<a class="resource__post-image"
alt="{{ rec_post.featured_image_alt_text }}"
style="background-image: url('{{ rec_post.featured_image }}');"
href="{{ rec_post.absolute_url }}">
</a>

{% endif %}
{% set featured_tag = rec_post.topic_list | first %}
{% if featured_tag %}
<div class="content content-description">
<div>
<span class="keyword">{{ featured_tag }}</span>
{% endif %}
<h3><a href="{{ rec_post.absolute_url }}">{{ rec_post.name }}</a></h3>
<p class="description">{{ content.meta_description | default(content.post_summary, true) | truncatehtml(150, '...', false) }}</p>
</div>
<div>
<a class="ghost-cta" href="{{ rec_post.absolute_url }}">
Read more
</a>
</div>
</div>
</div>
</li>
{% endfor %}
</ul>

Resources 2022-07-20 18-35-14.png

0 いいね!
1件の承認済みベストアンサー
albertsg
解決策
ガイド役

Latest POSTS description not showing

解決

Hello @CHugo, the description comes from:

 

<p class="description">{{ content.meta_description | default(content.post_summary, true) | truncatehtml(150, '...', false) }}</p>

 

And based on your code, it should print the content.post_summary variable unless there is a Meta Description in content.meta_description.

 

Based on my experience dealing with content issues, did you by any chance clone the articles and changed everything except the meta descriptions? If that's the case, your code might be correct but the issue lays on all posts having the same meta description. Since in your screenshot all posts have the same text, it looks like this might be the problem 🙂

 

If what I mentioned above is correct and you still want to keep the meta descriptions the same across blog posts, then change the code to:

 

<p class="description">{{ content.post_summary | default(content.meta_description, true) | truncatehtml(150, '...', false) }}</p>

 

In the code above, you will always show the post_summary as default variable and in case this doesn't exists, the meta description will be shown.

 

If none of that helps, I recommend you checking the |default filter documentation to know more about it since you might not need it or you might not need the true parameter: https://developers.hubspot.com/docs/cms/hubl/filters#default



Did my answer help you? Mark it as a solution


Book time with me

You can also connect with me on LinkedIn



元の投稿で解決策を見る

1件の返信
albertsg
解決策
ガイド役

Latest POSTS description not showing

解決

Hello @CHugo, the description comes from:

 

<p class="description">{{ content.meta_description | default(content.post_summary, true) | truncatehtml(150, '...', false) }}</p>

 

And based on your code, it should print the content.post_summary variable unless there is a Meta Description in content.meta_description.

 

Based on my experience dealing with content issues, did you by any chance clone the articles and changed everything except the meta descriptions? If that's the case, your code might be correct but the issue lays on all posts having the same meta description. Since in your screenshot all posts have the same text, it looks like this might be the problem 🙂

 

If what I mentioned above is correct and you still want to keep the meta descriptions the same across blog posts, then change the code to:

 

<p class="description">{{ content.post_summary | default(content.meta_description, true) | truncatehtml(150, '...', false) }}</p>

 

In the code above, you will always show the post_summary as default variable and in case this doesn't exists, the meta description will be shown.

 

If none of that helps, I recommend you checking the |default filter documentation to know more about it since you might not need it or you might not need the true parameter: https://developers.hubspot.com/docs/cms/hubl/filters#default



Did my answer help you? Mark it as a solution


Book time with me

You can also connect with me on LinkedIn