CMS Development

MichalMocko
Member

How to add topic/tag to the post

SOLVE

Hello guys,

 

I know it has been probably answered here already, but still I am doing something wrong.

 

I am completely new to Hubspot so bear with me - I would like to add topic/tag right next to other metadata of each blog post on blog index. I have seen several similar questions but I could not find a working solution for me.

 

This is my code:

{% for content in contents %}
      {# On the blog homepage the first post will be featured above older posts #}

        <a class="post-item {% if not content.post_list_summary_featured_image %}no-img {% endif %}" href="{{ content.absolute_url }}">
          <div class="pwr-3D-box">
            <div class="pwr-post-item__content ">
                {% if content.post_list_summary_featured_image %}
              <div class="pwr-post-item__img" style="background-image: url({{ content.post_list_summary_featured_image }});"></div>
              {% endif %}
              <div class="pwr-post-item__overlay"></div>
              <div class="pwr-post-item__info-box">
                <div class="pwr-post-item__author">
                    {% if content.blog_post_author %}
                  <span class="pwr-post-item__name">{{ content.blog_post_author.display_name }}</span>
                                                  
                  {% endif %}
                  <span class="pwr-post-item__date">{{ content.publish_date_local_time.strftime('%d.%m.%Y') }}</span>
                                                   
                                                  
                  <span class="pwr-post-item__n-min-read">
                      {% set initialPostWords = content.post_body|striptags|wordcount %}
                      {% set calculatedPostWords = (initialPostWords/100) * 100 %}
                      {% set finishedPostWords = calculatedPostWords|divide(300)|round(2) %}
                      {% set number = finishedPostWords|round %}
                      {% if number < 1 %}
                      {% else %}
                      {{ finishedPostWords|round }}min čtení
                      {% endif %}
                      </span>
                                                         
                                                    
                                                         
                </div>
                <h2 class="pwr-post-item__title">{{ content.name }}</h2>
                <div class="pwr-post-item__desc">
                    {{ content.post_list_content|striptags|truncatehtml(100, '...' , false) }} 
                  
                
                    
                
            
            
              
            </p>
                  
                </div>
                <span class="pwr-post-item__more-link">Přejít na článek<span class="pwr-link-icon "><span>
                  <svg version="1.0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" aria-hidden="true"><g id="layer1"><path d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></g></svg></span></span>
                </span>
              </div>
            </div>
          </div>
        </a>



    {% endfor %}
0 Upvotes
1 Accepted solution
stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

How to add topic/tag to the post

SOLVE

@MichalMocko the variable you're looking for is {{ contents_topics }}

 

I believe this is a sequence of topics so you'll want to loop through them like so:

 

{% for topic in content.contents_topics %}
{{ topic.name }}
{% endfor %
Stefen Phelps, Community Champion, Kelp Web Developer

View solution in original post

2 Replies 2
stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

How to add topic/tag to the post

SOLVE

@MichalMocko the variable you're looking for is {{ contents_topics }}

 

I believe this is a sequence of topics so you'll want to loop through them like so:

 

{% for topic in content.contents_topics %}
{{ topic.name }}
{% endfor %
Stefen Phelps, Community Champion, Kelp Web Developer
sharonlicari
Community Manager
Community Manager

How to add topic/tag to the post

SOLVE

Hey @MichalMocko 

 

Thank you for the information provided.I'll tag a few experts that can share their experience with you.    

 

Hey  @Chris-M @stefen @alyssamwilie  any thoughts you would like to share with @MichalMocko

 

Thanks & Happy Friday

 

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes