Text Link

This is the line from the body text of a blog feed module. I would like to add a link to the blog post from the words “Read More”.

<p>{{ post.post_body|safe|striptags|truncate(130, true, ‘…READ MORE’) }}</p>

Would I plug in this line?

<a href=“{{ post.absolute_url }}”>READ MORE</a>

Can someone help me? Or am I not providing enough of the code?

Hey @MNault,

Yes I believe that line of code should work, you may have to remove the Read More part in the above <p> tags so it doesn’t get repeated.

Hey @MNault

Welcome to the Community!

That looks about right. Easiest thing to do is test it! Should be able to look at the live preview.

Not sure what the plans are for the READ MORE you have in the paragraph is. Either will need to remove it or add make it look like this

<p>{{ content.post_body|safe|striptags|truncate(130, true, ' <a href="{{ content.absolute_url }}">...READ MORE</a>') }} </p>

Hmmm, I added that to the line of code and the entire blog body text disapeared. This is the live page, you can see the three blog posts. There are ellipsis at the end of each and we want to add READ MORE which then links the entire blog post.

https://info.redpathcpas.com/construction-real-estate-and-engineering

Interesting, can you copy the code you have that is within the “blog-item-post” class so we can take a closer look?

<div class=“blog-item-post”>

<h3><a href=“{{ post.absolute_url }}”>{{ post.name }}</a></h3>

<div class=“blog-item-meta {{ ‘margin-bottom’ if post.post_body }}”>

<span class=“author-icon”>

{% icon

name=“{{ module.blog_item_style.icons.author.name }}”

style=“{{ module.blog_item_style.icons.author.type }}”

unicode=“{{ module.blog_item_style.icons.author.unicode }}”

%}

</span>

<a href=“https://{{ post.parent_blog.url_base }}{{ ‘/author/’~post.blog_author.slug }}” class=“blog-author”>{{ post.blog_author }}</a>

<span class=“date-posted”>

<span class=“date-icon”>

{% icon

name=“{{ module.blog_item_style.icons.date_icon.name }}”

style=“{{ module.blog_item_style.icons.date_icon.type }}”

unicode=“{{ module.blog_item_style.icons.date_icon.unicode }}”

%}

</span>

{{ post.created|datetimeformat(“%B %e, %Y”) }}</span>

{% if module.blog_list_settings.tag_style_settings.show_tag_in_blog_feed %}

{% if post.topic_list %}

<p class=“hubspot-topic_data”>

{% for topic in post.topic_list %}

<a class=“topic-link” href=“{{ blog_tag_url(group.id, topic.slug) }}”>{{ topic.name }}</a>

{% endfor %}

</p>

{% endif %}

{% endif %}

</div>

<p>{{ post.post_body|safe|striptags|truncate(130, true, ‘…’) }}</p>

</div>

</div>

</div>

Thanks, you should be able to just add that line like this right under post body preview

 </div>
 <p>{{ post.post_body|safe|striptags|truncate(130, true, '...') }}</p>
 <a href="{{ post.absolute_url }}">Read More</a> 
 </div>

Actually, I was hoping it would link to the appropriate full blog post but it just returns to the same page.

hey @MNault

Can you confirm that you updated this line

<p>{{ post.post_body|safe|striptags|truncate(130, true, ' <a href="{{ content.absolute_url }}">...READ MORE</a>') }} </p>

to make it be

<p>{{ post.post_body|safe|striptags|truncate(130, true, ' <a href="{{ post.absolute_url }}">...READ MORE</a>') }} </p>

Ooops, sorry, I missed the second “post” - It works brilliantly now! THank you so much @dennisedson and @jonchim I appreciate this so much!!

If you were inputing my code snippet directly, replace content with post (apologies for that!)

oops! @jonchim beat me to the punch!

haha @dennisedson :grinning_face: i like your solution more didn’t realize you can include the a tags in there altogether.

@MNault, the code @dennisedson works as well didn’t see that content. but changing it to post. works saves a line of code!